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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(predicate:, statements:, consequent:, location:, comments: []) ⇒ Unless
9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 |
# File 'lib/syntax_tree/node.rb', line 9409 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
9407 9408 9409 |
# File 'lib/syntax_tree/node.rb', line 9407 def comments @comments end |
#consequent ⇒ Object (readonly)
- nil, Elsif, Else
-
the next clause in the chain
9404 9405 9406 |
# File 'lib/syntax_tree/node.rb', line 9404 def consequent @consequent end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
9398 9399 9400 |
# File 'lib/syntax_tree/node.rb', line 9398 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
9401 9402 9403 |
# File 'lib/syntax_tree/node.rb', line 9401 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
9423 9424 9425 |
# File 'lib/syntax_tree/node.rb', line 9423 def accept(visitor) visitor.visit_unless(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9427 9428 9429 |
# File 'lib/syntax_tree/node.rb', line 9427 def child_nodes [predicate, statements, consequent] end |
#deconstruct_keys(_keys) ⇒ Object
9433 9434 9435 9436 9437 9438 9439 9440 9441 |
# File 'lib/syntax_tree/node.rb', line 9433 def deconstruct_keys(_keys) { predicate: predicate, statements: statements, consequent: consequent, location: location, comments: comments } end |
#format(q) ⇒ Object
9443 9444 9445 |
# File 'lib/syntax_tree/node.rb', line 9443 def format(q) ConditionalFormatter.new("unless", self).format(q) end |