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, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ GVar
5508
5509
5510
5511
5512
|
# File 'lib/syntax_tree/node.rb', line 5508
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5506
5507
5508
|
# File 'lib/syntax_tree/node.rb', line 5506
def
end
|
#value ⇒ Object
- String
-
the name of the global variable
5503
5504
5505
|
# File 'lib/syntax_tree/node.rb', line 5503
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5543
5544
5545
|
# File 'lib/syntax_tree/node.rb', line 5543
def ===(other)
other.is_a?(GVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
5514
5515
5516
|
# File 'lib/syntax_tree/node.rb', line 5514
def accept(visitor)
visitor.visit_gvar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
5518
5519
5520
|
# File 'lib/syntax_tree/node.rb', line 5518
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
|
# File 'lib/syntax_tree/node.rb', line 5522
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
5535
5536
5537
|
# File 'lib/syntax_tree/node.rb', line 5535
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
5539
5540
5541
|
# File 'lib/syntax_tree/node.rb', line 5539
def format(q)
q.text(value)
end
|