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
Constructor Details
#initialize(value:, location:, comments: []) ⇒ VarRef
Returns a new instance of VarRef.
8697 8698 8699 8700 8701 |
# File 'lib/syntax_tree/node.rb', line 8697 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
8695 8696 8697 |
# File 'lib/syntax_tree/node.rb', line 8695 def comments @comments end |
#value ⇒ Object (readonly)
- Const | CVar | GVar | Ident | IVar | Kw
-
the value of this node
8692 8693 8694 |
# File 'lib/syntax_tree/node.rb', line 8692 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
8703 8704 8705 |
# File 'lib/syntax_tree/node.rb', line 8703 def accept(visitor) visitor.visit_var_ref(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8707 8708 8709 |
# File 'lib/syntax_tree/node.rb', line 8707 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
8713 8714 8715 |
# File 'lib/syntax_tree/node.rb', line 8713 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
8717 8718 8719 |
# File 'lib/syntax_tree/node.rb', line 8717 def format(q) q.format(value) end |