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
Constructor Details
#initialize(predicate:, statements:, location:, comments: []) ⇒ Until
Returns a new instance of Until.
9051 9052 9053 9054 9055 9056 |
# File 'lib/syntax_tree/node.rb', line 9051 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
9049 9050 9051 |
# File 'lib/syntax_tree/node.rb', line 9049 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
9043 9044 9045 |
# File 'lib/syntax_tree/node.rb', line 9043 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
9046 9047 9048 |
# File 'lib/syntax_tree/node.rb', line 9046 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
9058 9059 9060 |
# File 'lib/syntax_tree/node.rb', line 9058 def accept(visitor) visitor.visit_until(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9062 9063 9064 |
# File 'lib/syntax_tree/node.rb', line 9062 def child_nodes [predicate, statements] end |
#deconstruct_keys(keys) ⇒ Object
9068 9069 9070 9071 9072 9073 9074 9075 |
# File 'lib/syntax_tree/node.rb', line 9068 def deconstruct_keys(keys) { predicate: predicate, statements: statements, location: location, comments: comments } end |
#format(q) ⇒ Object
9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 |
# File 'lib/syntax_tree/node.rb', line 9077 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 |