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
Returns a new instance of Unless.
9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 |
# File 'lib/syntax_tree/node.rb', line 9192 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
9190 9191 9192 |
# File 'lib/syntax_tree/node.rb', line 9190 def comments @comments end |
#consequent ⇒ Object (readonly)
- nil, Elsif, Else
-
the next clause in the chain
9187 9188 9189 |
# File 'lib/syntax_tree/node.rb', line 9187 def consequent @consequent end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
9181 9182 9183 |
# File 'lib/syntax_tree/node.rb', line 9181 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
9184 9185 9186 |
# File 'lib/syntax_tree/node.rb', line 9184 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
9206 9207 9208 |
# File 'lib/syntax_tree/node.rb', line 9206 def accept(visitor) visitor.visit_unless(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9210 9211 9212 |
# File 'lib/syntax_tree/node.rb', line 9210 def child_nodes [predicate, statements, consequent] end |
#deconstruct_keys(_keys) ⇒ Object
9216 9217 9218 9219 9220 9221 9222 9223 9224 |
# File 'lib/syntax_tree/node.rb', line 9216 def deconstruct_keys(_keys) { predicate: predicate, statements: statements, consequent: consequent, location: location, comments: comments } end |
#format(q) ⇒ Object
9226 9227 9228 |
# File 'lib/syntax_tree/node.rb', line 9226 def format(q) ConditionalFormatter.new("unless", self).format(q) end |