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.
9559 9560 9561 9562 9563 9564 |
# File 'lib/syntax_tree/node.rb', line 9559 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
9557 9558 9559 |
# File 'lib/syntax_tree/node.rb', line 9557 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
9551 9552 9553 |
# File 'lib/syntax_tree/node.rb', line 9551 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
9554 9555 9556 |
# File 'lib/syntax_tree/node.rb', line 9554 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
9566 9567 9568 |
# File 'lib/syntax_tree/node.rb', line 9566 def accept(visitor) visitor.visit_until(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9570 9571 9572 |
# File 'lib/syntax_tree/node.rb', line 9570 def child_nodes [predicate, statements] end |
#deconstruct_keys(_keys) ⇒ Object
9576 9577 9578 9579 9580 9581 9582 9583 |
# File 'lib/syntax_tree/node.rb', line 9576 def deconstruct_keys(_keys) { predicate: predicate, statements: statements, location: location, comments: comments } end |
#format(q) ⇒ Object
9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 |
# File 'lib/syntax_tree/node.rb', line 9585 def format(q) if statements.empty? keyword = "until " q.group do q.text(keyword) q.nest(keyword.length) { q.format(predicate) } q.breakable_force q.text("end") end else LoopFormatter.new("until", self, statements).format(q) end end |