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.
9462 9463 9464 9465 9466 9467 |
# File 'lib/syntax_tree/node.rb', line 9462 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
9460 9461 9462 |
# File 'lib/syntax_tree/node.rb', line 9460 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
9457 9458 9459 |
# File 'lib/syntax_tree/node.rb', line 9457 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
9454 9455 9456 |
# File 'lib/syntax_tree/node.rb', line 9454 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
9469 9470 9471 |
# File 'lib/syntax_tree/node.rb', line 9469 def accept(visitor) visitor.visit_unless_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9473 9474 9475 |
# File 'lib/syntax_tree/node.rb', line 9473 def child_nodes [statement, predicate] end |
#deconstruct_keys(_keys) ⇒ Object
9479 9480 9481 9482 9483 9484 9485 9486 |
# File 'lib/syntax_tree/node.rb', line 9479 def deconstruct_keys(_keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
9488 9489 9490 |
# File 'lib/syntax_tree/node.rb', line 9488 def format(q) ConditionalModFormatter.new("unless", self).format(q) end |