Class: SyntaxTree::VarRef
Overview
VarRef represents a variable reference.
true
This can be a plain local variable like the example above. It can also be a constant, a class variable, a global variable, an instance variable, a keyword (like self, nil, true, or false), or a numbered block variable.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- Const | CVar | GVar | Ident | IVar | Kw
-
the value 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: []) ⇒ VarRef
constructor
A new instance of VarRef.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:, comments: []) ⇒ VarRef
Returns a new instance of VarRef.
9451 9452 9453 9454 9455 |
# File 'lib/syntax_tree/node.rb', line 9451 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
9449 9450 9451 |
# File 'lib/syntax_tree/node.rb', line 9449 def comments @comments end |
#value ⇒ Object (readonly)
- Const | CVar | GVar | Ident | IVar | Kw
-
the value of this node
9446 9447 9448 |
# File 'lib/syntax_tree/node.rb', line 9446 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
9457 9458 9459 |
# File 'lib/syntax_tree/node.rb', line 9457 def accept(visitor) visitor.visit_var_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9461 9462 9463 |
# File 'lib/syntax_tree/node.rb', line 9461 def child_nodes [value] end |
#deconstruct_keys(_keys) ⇒ Object
9467 9468 9469 |
# File 'lib/syntax_tree/node.rb', line 9467 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
9471 9472 9473 |
# File 'lib/syntax_tree/node.rb', line 9471 def format(q) q.format(value) end |