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.
5499
5500
5501
5502
5503
|
# File 'lib/syntax_tree/node.rb', line 5499
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5497
5498
5499
|
# File 'lib/syntax_tree/node.rb', line 5497
def
@comments
end
|
#value ⇒ Object
- String
-
the name of the global variable
5494
5495
5496
|
# File 'lib/syntax_tree/node.rb', line 5494
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
5534
5535
5536
|
# File 'lib/syntax_tree/node.rb', line 5534
def ===(other)
other.is_a?(GVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
5505
5506
5507
|
# File 'lib/syntax_tree/node.rb', line 5505
def accept(visitor)
visitor.visit_gvar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
5509
5510
5511
|
# File 'lib/syntax_tree/node.rb', line 5509
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
|
# File 'lib/syntax_tree/node.rb', line 5513
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
5526
5527
5528
|
# File 'lib/syntax_tree/node.rb', line 5526
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
5530
5531
5532
|
# File 'lib/syntax_tree/node.rb', line 5530
def format(q)
q.text(value)
end
|