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.
5584 5585 5586 5587 5588 5589 |
# File 'lib/syntax_tree/node.rb', line 5584 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
5582 5583 5584 |
# File 'lib/syntax_tree/node.rb', line 5582 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
5579 5580 5581 |
# File 'lib/syntax_tree/node.rb', line 5579 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
5576 5577 5578 |
# File 'lib/syntax_tree/node.rb', line 5576 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
5591 5592 5593 |
# File 'lib/syntax_tree/node.rb', line 5591 def accept(visitor) visitor.visit_if_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5595 5596 5597 |
# File 'lib/syntax_tree/node.rb', line 5595 def child_nodes [statement, predicate] end |
#deconstruct_keys(_keys) ⇒ Object
5601 5602 5603 5604 5605 5606 5607 5608 |
# File 'lib/syntax_tree/node.rb', line 5601 def deconstruct_keys(_keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
5610 5611 5612 |
# File 'lib/syntax_tree/node.rb', line 5610 def format(q) ConditionalModFormatter.new("if", self).format(q) end |