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
Constructor Details
#initialize(statement:, predicate:, location:, comments: []) ⇒ IfMod
Returns a new instance of IfMod.
5415 5416 5417 5418 5419 5420 |
# File 'lib/syntax_tree/node.rb', line 5415 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
5413 5414 5415 |
# File 'lib/syntax_tree/node.rb', line 5413 def comments @comments end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
5410 5411 5412 |
# File 'lib/syntax_tree/node.rb', line 5410 def predicate @predicate end |
#statement ⇒ Object (readonly)
- untyped
-
the expression to be executed
5407 5408 5409 |
# File 'lib/syntax_tree/node.rb', line 5407 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
5422 5423 5424 |
# File 'lib/syntax_tree/node.rb', line 5422 def accept(visitor) visitor.visit_if_mod(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5426 5427 5428 |
# File 'lib/syntax_tree/node.rb', line 5426 def child_nodes [statement, predicate] end |
#deconstruct_keys(keys) ⇒ Object
5432 5433 5434 5435 5436 5437 5438 5439 |
# File 'lib/syntax_tree/node.rb', line 5432 def deconstruct_keys(keys) { statement: statement, predicate: predicate, location: location, comments: comments } end |
#format(q) ⇒ Object
5441 5442 5443 |
# File 'lib/syntax_tree/node.rb', line 5441 def format(q) ConditionalModFormatter.new("if", self).format(q) end |