Class: SyntaxTree::UntilNode
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::UntilNode
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Until represents an until
loop.
until predicate
end
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(predicate:, statements:, location:) ⇒ UntilNode
Returns a new instance of UntilNode.
11447
11448
11449
11450
11451
11452
|
# File 'lib/syntax_tree/node.rb', line 11447
def initialize(predicate:, statements:, location:)
@predicate = predicate
@statements = statements
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11445
11446
11447
|
# File 'lib/syntax_tree/node.rb', line 11445
def
@comments
end
|
#predicate ⇒ Object
- Node
-
the expression to be checked
11439
11440
11441
|
# File 'lib/syntax_tree/node.rb', line 11439
def predicate
@predicate
end
|
#statements ⇒ Object
- Statements
-
the expressions to be executed
11442
11443
11444
|
# File 'lib/syntax_tree/node.rb', line 11442
def statements
@statements
end
|
Instance Method Details
#===(other) ⇒ Object
11489
11490
11491
11492
|
# File 'lib/syntax_tree/node.rb', line 11489
def ===(other)
other.is_a?(UntilNode) && predicate === other.predicate &&
statements === other.statements
end
|
#accept(visitor) ⇒ Object
11454
11455
11456
|
# File 'lib/syntax_tree/node.rb', line 11454
def accept(visitor)
visitor.visit_until(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11458
11459
11460
|
# File 'lib/syntax_tree/node.rb', line 11458
def child_nodes
[predicate, statements]
end
|
#copy(predicate: nil, statements: nil, location: nil) ⇒ Object
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
|
# File 'lib/syntax_tree/node.rb', line 11462
def copy(predicate: nil, statements: nil, location: nil)
node =
UntilNode.new(
predicate: predicate || self.predicate,
statements: statements || self.statements,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
11476
11477
11478
11479
11480
11481
11482
11483
|
# File 'lib/syntax_tree/node.rb', line 11476
def deconstruct_keys(_keys)
{
predicate: predicate,
statements: statements,
location: location,
comments:
}
end
|
11485
11486
11487
|
# File 'lib/syntax_tree/node.rb', line 11485
def format(q)
LoopFormatter.new("until", self).format(q)
end
|
#modifier? ⇒ Boolean
11494
11495
11496
|
# File 'lib/syntax_tree/node.rb', line 11494
def modifier?
predicate.location.start_char > statements.location.start_char
end
|