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
Returns a new instance of GVar.
5494
5495
5496
5497
5498
|
# File 'lib/syntax_tree/node.rb', line 5494
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5492
5493
5494
|
# File 'lib/syntax_tree/node.rb', line 5492
def
@comments
end
|
#value ⇒ Object
- String
-
the name of the global variable
5489
5490
5491
|
# File 'lib/syntax_tree/node.rb', line 5489
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5529
5530
5531
|
# File 'lib/syntax_tree/node.rb', line 5529
def ===(other)
other.is_a?(GVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
5500
5501
5502
|
# File 'lib/syntax_tree/node.rb', line 5500
def accept(visitor)
visitor.visit_gvar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
5504
5505
5506
|
# File 'lib/syntax_tree/node.rb', line 5504
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
|
# File 'lib/syntax_tree/node.rb', line 5508
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
5521
5522
5523
|
# File 'lib/syntax_tree/node.rb', line 5521
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
5525
5526
5527
|
# File 'lib/syntax_tree/node.rb', line 5525
def format(q)
q.text(value)
end
|