Class: SyntaxTree::VarField
Overview
VarField represents a variable that is being assigned a value. As such, it is always a child of an assignment type node.
variable = value
In the example above, the VarField node represents the variable token.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- nil | Const | CVar | GVar | Ident | IVar
-
the target of this node.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ VarField
constructor
A new instance of VarField.
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ VarField
Returns a new instance of VarField.
8657 8658 8659 8660 8661 |
# File 'lib/syntax_tree/node.rb', line 8657 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8655 8656 8657 |
# File 'lib/syntax_tree/node.rb', line 8655 def comments @comments end |
#value ⇒ Object (readonly)
- nil | Const | CVar | GVar | Ident | IVar
-
the target of this node
8652 8653 8654 |
# File 'lib/syntax_tree/node.rb', line 8652 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
8663 8664 8665 |
# File 'lib/syntax_tree/node.rb', line 8663 def accept(visitor) visitor.visit_var_field(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8667 8668 8669 |
# File 'lib/syntax_tree/node.rb', line 8667 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
8673 8674 8675 |
# File 'lib/syntax_tree/node.rb', line 8673 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
8677 8678 8679 |
# File 'lib/syntax_tree/node.rb', line 8677 def format(q) q.format(value) if value end |