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, #pretty_print, #to_json
Constructor Details
#initialize(predicate:, statements:, location:) ⇒ UntilNode
Returns a new instance of UntilNode.
11288
11289
11290
11291
11292
11293
|
# File 'lib/syntax_tree/node.rb', line 11288
def initialize(predicate:, statements:, location:)
@predicate = predicate
@statements = statements
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11286
11287
11288
|
# File 'lib/syntax_tree/node.rb', line 11286
def
end
|
#predicate ⇒ Object
- untyped
-
the expression to be checked
11280
11281
11282
|
# File 'lib/syntax_tree/node.rb', line 11280
def predicate
@predicate
end
|
#statements ⇒ Object
- Statements
-
the expressions to be executed
11283
11284
11285
|
# File 'lib/syntax_tree/node.rb', line 11283
def statements
@statements
end
|
Instance Method Details
#===(other) ⇒ Object
11330
11331
11332
11333
|
# File 'lib/syntax_tree/node.rb', line 11330
def ===(other)
other.is_a?(UntilNode) && predicate === other.predicate &&
statements === other.statements
end
|
#accept(visitor) ⇒ Object
11295
11296
11297
|
# File 'lib/syntax_tree/node.rb', line 11295
def accept(visitor)
visitor.visit_until(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11299
11300
11301
|
# File 'lib/syntax_tree/node.rb', line 11299
def child_nodes
[predicate, statements]
end
|
#copy(predicate: nil, statements: nil, location: nil) ⇒ Object
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
|
# File 'lib/syntax_tree/node.rb', line 11303
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
11317
11318
11319
11320
11321
11322
11323
11324
|
# File 'lib/syntax_tree/node.rb', line 11317
def deconstruct_keys(_keys)
{
predicate: predicate,
statements: statements,
location: location,
comments:
}
end
|
11326
11327
11328
|
# File 'lib/syntax_tree/node.rb', line 11326
def format(q)
LoopFormatter.new("until", self).format(q)
end
|
#modifier? ⇒ Boolean
11335
11336
11337
|
# File 'lib/syntax_tree/node.rb', line 11335
def modifier?
predicate.location.start_char > statements.location.start_char
end
|