class SyntaxTree::Else
Else
represents the end of an if
, unless
, or case
chain.
if variable else end
Attributes
Kw
-
the else keyword
Statements
-
the expressions to be executed
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 4817 def initialize(keyword:, statements:, location:) @keyword = keyword @statements = statements @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 4868 def ===(other) other.is_a?(Else) && keyword === other.keyword && statements === other.statements end
Source
# File lib/syntax_tree/node.rb, line 4824 def accept(visitor) visitor.visit_else(self) end
Source
# File lib/syntax_tree/node.rb, line 4828 def child_nodes [keyword, statements] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 4832 def copy(keyword: nil, statements: nil, location: nil) node = Else.new( keyword: keyword || self.keyword, statements: statements || self.statements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 4846 def deconstruct_keys(_keys) { keyword: keyword, statements: statements, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 4855 def format(q) q.group do q.format(keyword) unless statements.empty? q.indent do q.breakable_force q.format(statements) end end end end