Class: SyntaxTree::Unless
Overview
Unless represents the first clause in an unless chain.
unless predicate
end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#consequent ⇒ Object
readonly
- nil, Elsif, Else
-
the next clause in the chain.
-
#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:, consequent:, location:, comments: []) ⇒ Unless
constructor
A new instance of Unless.
Methods inherited from Node
Constructor Details
#initialize(predicate:, statements:, consequent:, location:, comments: []) ⇒ Unless
Returns a new instance of Unless.
8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 |
# File 'lib/syntax_tree/node.rb', line 8343 def initialize( predicate:, statements:, consequent:, location:, comments: [] ) @predicate = predicate @statements = statements @consequent = consequent @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8341 8342 8343 |
# File 'lib/syntax_tree/node.rb', line 8341 def comments @comments end |
#consequent ⇒ Object (readonly)
- nil, Elsif, Else
-
the next clause in the chain
8338 8339 8340 |
# File 'lib/syntax_tree/node.rb', line 8338 def consequent @consequent end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
8332 8333 8334 |
# File 'lib/syntax_tree/node.rb', line 8332 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
8335 8336 8337 |
# File 'lib/syntax_tree/node.rb', line 8335 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
8357 8358 8359 |
# File 'lib/syntax_tree/node.rb', line 8357 def accept(visitor) visitor.visit_unless(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8361 8362 8363 |
# File 'lib/syntax_tree/node.rb', line 8361 def child_nodes [predicate, statements, consequent] end |
#deconstruct_keys(keys) ⇒ Object
8367 8368 8369 8370 8371 8372 8373 8374 8375 |
# File 'lib/syntax_tree/node.rb', line 8367 def deconstruct_keys(keys) { predicate: predicate, statements: statements, consequent: consequent, location: location, comments: comments } end |
#format(q) ⇒ Object
8377 8378 8379 |
# File 'lib/syntax_tree/node.rb', line 8377 def format(q) ConditionalFormatter.new("unless", self).format(q) end |