Class: SyntaxTree::IfMod
Overview
IfMod represents the modifier form of an if
statement.
expression if 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: []) ⇒ IfMod
constructor
A new instance of IfMod.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(statement:, predicate:, location:, comments: []) ⇒ IfMod
Returns a new instance of IfMod.
5545 5546 5547 5548 5549 5550 |
# File 'lib/syntax_tree/node.rb', line 5545 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
5543 5544 5545 |
# File 'lib/syntax_tree/node.rb', line 5543 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
5540 5541 5542 |
# File 'lib/syntax_tree/node.rb', line 5540 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
5537 5538 5539 |
# File 'lib/syntax_tree/node.rb', line 5537 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
5552 5553 5554 |
# File 'lib/syntax_tree/node.rb', line 5552 def accept(visitor) visitor.visit_if_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5556 5557 5558 |
# File 'lib/syntax_tree/node.rb', line 5556 def child_nodes [statement, predicate] end |
#deconstruct_keys(_keys) ⇒ Object
5562 5563 5564 5565 5566 5567 5568 5569 |
# File 'lib/syntax_tree/node.rb', line 5562 def deconstruct_keys(_keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
5571 5572 5573 |
# File 'lib/syntax_tree/node.rb', line 5571 def format(q) ConditionalModFormatter.new("if", self).format(q) end |