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.
9228 9229 9230 9231 9232 9233 |
# File 'lib/syntax_tree/node.rb', line 9228 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
9226 9227 9228 |
# File 'lib/syntax_tree/node.rb', line 9226 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
9223 9224 9225 |
# File 'lib/syntax_tree/node.rb', line 9223 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
9220 9221 9222 |
# File 'lib/syntax_tree/node.rb', line 9220 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
9235 9236 9237 |
# File 'lib/syntax_tree/node.rb', line 9235 def accept(visitor) visitor.visit_unless_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9239 9240 9241 |
# File 'lib/syntax_tree/node.rb', line 9239 def child_nodes [statement, predicate] end |
#deconstruct_keys(_keys) ⇒ Object
9245 9246 9247 9248 9249 9250 9251 9252 |
# File 'lib/syntax_tree/node.rb', line 9245 def deconstruct_keys(_keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
9254 9255 9256 |
# File 'lib/syntax_tree/node.rb', line 9254 def format(q) ConditionalModFormatter.new("unless", self).format(q) end |