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.
11480
11481
11482
11483
11484
11485
|
# File 'lib/syntax_tree/node.rb', line 11480
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
11478
11479
11480
|
# File 'lib/syntax_tree/node.rb', line 11478
def
@comments
end
|
#predicate ⇒ Object
- Node
-
the expression to be checked
11472
11473
11474
|
# File 'lib/syntax_tree/node.rb', line 11472
def predicate
@predicate
end
|
#statements ⇒ Object
- Statements
-
the expressions to be executed
11475
11476
11477
|
# File 'lib/syntax_tree/node.rb', line 11475
def statements
@statements
end
|
Instance Method Details
#===(other) ⇒ Object
11522
11523
11524
11525
|
# File 'lib/syntax_tree/node.rb', line 11522
def ===(other)
other.is_a?(UntilNode) && predicate === other.predicate &&
statements === other.statements
end
|
#accept(visitor) ⇒ Object
11487
11488
11489
|
# File 'lib/syntax_tree/node.rb', line 11487
def accept(visitor)
visitor.visit_until(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11491
11492
11493
|
# File 'lib/syntax_tree/node.rb', line 11491
def child_nodes
[predicate, statements]
end
|
#copy(predicate: nil, statements: nil, location: nil) ⇒ Object
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
|
# File 'lib/syntax_tree/node.rb', line 11495
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
11509
11510
11511
11512
11513
11514
11515
11516
|
# File 'lib/syntax_tree/node.rb', line 11509
def deconstruct_keys(_keys)
{
predicate: predicate,
statements: statements,
location: location,
comments:
}
end
|
11518
11519
11520
|
# File 'lib/syntax_tree/node.rb', line 11518
def format(q)
LoopFormatter.new("until", self).format(q)
end
|
#modifier? ⇒ Boolean
11527
11528
11529
|
# File 'lib/syntax_tree/node.rb', line 11527
def modifier?
predicate.location.start_char > statements.location.start_char
end
|