Class: SyntaxTree::Until
Overview
Until represents an until loop.
until predicate
end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#predicate ⇒ Object
readonly
- untyped
-
the expression to be checked.
-
#statements ⇒ Object
readonly
- Statements
-
the expressions to be executed.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(predicate:, statements:, location:, comments: []) ⇒ Until
constructor
A new instance of Until.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(predicate:, statements:, location:, comments: []) ⇒ Until
Returns a new instance of Until.
9342 9343 9344 9345 9346 9347 |
# File 'lib/syntax_tree/node.rb', line 9342 def initialize(predicate:, statements:, location:, comments: []) @predicate = predicate @statements = statements @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9340 9341 9342 |
# File 'lib/syntax_tree/node.rb', line 9340 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
9334 9335 9336 |
# File 'lib/syntax_tree/node.rb', line 9334 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
9337 9338 9339 |
# File 'lib/syntax_tree/node.rb', line 9337 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
9349 9350 9351 |
# File 'lib/syntax_tree/node.rb', line 9349 def accept(visitor) visitor.visit_until(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9353 9354 9355 |
# File 'lib/syntax_tree/node.rb', line 9353 def child_nodes [predicate, statements] end |
#deconstruct_keys(_keys) ⇒ Object
9359 9360 9361 9362 9363 9364 9365 9366 |
# File 'lib/syntax_tree/node.rb', line 9359 def deconstruct_keys(_keys) { predicate: predicate, statements: statements, location: location, comments: comments } end |
#format(q) ⇒ Object
9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 |
# File 'lib/syntax_tree/node.rb', line 9368 def format(q) if statements.empty? keyword = "until " q.group do q.text(keyword) q.nest(keyword.length) { q.format(predicate) } q.breakable(force: true) q.text("end") end else LoopFormatter.new("until", self, statements).format(q) end end |