Class: SyntaxTree::If
Overview
If represents the first clause in an if chain.
if predicate
end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#consequent ⇒ Object
readonly
- nil, Elsif, Else
-
the next clause in the chain.
-
#predicate ⇒ Object
readonly
- untyped
-
the expression to be checked.
-
#statements ⇒ Object
readonly
- Statements
-
the expressions 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(predicate:, statements:, consequent:, location:, comments: []) ⇒ If
constructor
A new instance of If.
Methods inherited from Node
Constructor Details
#initialize(predicate:, statements:, consequent:, location:, comments: []) ⇒ If
Returns a new instance of If.
4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 |
# File 'lib/syntax_tree/node.rb', line 4697 def initialize( predicate:, statements:, consequent:, location:, comments: [] ) @predicate = predicate @statements = statements @consequent = consequent @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
4695 4696 4697 |
# File 'lib/syntax_tree/node.rb', line 4695 def comments @comments end |
#consequent ⇒ Object (readonly)
- nil, Elsif, Else
-
the next clause in the chain
4692 4693 4694 |
# File 'lib/syntax_tree/node.rb', line 4692 def consequent @consequent end |
#predicate ⇒ Object (readonly)
- untyped
-
the expression to be checked
4686 4687 4688 |
# File 'lib/syntax_tree/node.rb', line 4686 def predicate @predicate end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
4689 4690 4691 |
# File 'lib/syntax_tree/node.rb', line 4689 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
4711 4712 4713 |
# File 'lib/syntax_tree/node.rb', line 4711 def accept(visitor) visitor.visit_if(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
4715 4716 4717 |
# File 'lib/syntax_tree/node.rb', line 4715 def child_nodes [predicate, statements, consequent] end |
#deconstruct_keys(keys) ⇒ Object
4721 4722 4723 4724 4725 4726 4727 4728 4729 |
# File 'lib/syntax_tree/node.rb', line 4721 def deconstruct_keys(keys) { predicate: predicate, statements: statements, consequent: consequent, location: location, comments: comments } end |
#format(q) ⇒ Object
4731 4732 4733 |
# File 'lib/syntax_tree/node.rb', line 4731 def format(q) ConditionalFormatter.new("if", self).format(q) end |