Class: SyntaxTree::GVar
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::GVar
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
GVar represents a global variable literal.
$variable
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ GVar
Returns a new instance of GVar.
5607
5608
5609
5610
5611
|
# File 'lib/syntax_tree/node.rb', line 5607
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5605
5606
5607
|
# File 'lib/syntax_tree/node.rb', line 5605
def
@comments
end
|
#value ⇒ Object
- String
-
the name of the global variable
5602
5603
5604
|
# File 'lib/syntax_tree/node.rb', line 5602
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5642
5643
5644
|
# File 'lib/syntax_tree/node.rb', line 5642
def ===(other)
other.is_a?(GVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
5613
5614
5615
|
# File 'lib/syntax_tree/node.rb', line 5613
def accept(visitor)
visitor.visit_gvar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
5617
5618
5619
|
# File 'lib/syntax_tree/node.rb', line 5617
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
|
# File 'lib/syntax_tree/node.rb', line 5621
def copy(value: nil, location: nil)
node =
GVar.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
5634
5635
5636
|
# File 'lib/syntax_tree/node.rb', line 5634
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
5638
5639
5640
|
# File 'lib/syntax_tree/node.rb', line 5638
def format(q)
q.text(value)
end
|