Class: SyntaxTree::UnlessMod
Overview
UnlessMod represents the modifier form of an unless statement.
expression unless predicate
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.
-
#statement ⇒ Object
readonly
- untyped
-
the expression 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(statement:, predicate:, location:, comments: []) ⇒ UnlessMod
constructor
A new instance of UnlessMod.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(statement:, predicate:, location:, comments: []) ⇒ UnlessMod
Returns a new instance of UnlessMod.
9245 9246 9247 9248 9249 9250 |
# File 'lib/syntax_tree/node.rb', line 9245 def initialize(statement:, predicate:, location:, comments: []) @statement = statement @predicate = predicate @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9243 9244 9245 |
# File 'lib/syntax_tree/node.rb', line 9243 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
9240 9241 9242 |
# File 'lib/syntax_tree/node.rb', line 9240 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
9237 9238 9239 |
# File 'lib/syntax_tree/node.rb', line 9237 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
9252 9253 9254 |
# File 'lib/syntax_tree/node.rb', line 9252 def accept(visitor) visitor.visit_unless_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9256 9257 9258 |
# File 'lib/syntax_tree/node.rb', line 9256 def child_nodes [statement, predicate] end |
#deconstruct_keys(_keys) ⇒ Object
9262 9263 9264 9265 9266 9267 9268 9269 |
# File 'lib/syntax_tree/node.rb', line 9262 def deconstruct_keys(_keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
9271 9272 9273 |
# File 'lib/syntax_tree/node.rb', line 9271 def format(q) ConditionalModFormatter.new("unless", self).format(q) end |