Class: SyntaxTree::IVar
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::IVar
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
IVar represents an instance 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:) ⇒ IVar
Returns a new instance of IVar.
6767
6768
6769
6770
6771
|
# File 'lib/syntax_tree/node.rb', line 6767
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6765
6766
6767
|
# File 'lib/syntax_tree/node.rb', line 6765
def
@comments
end
|
#value ⇒ Object
- String
-
the name of the instance variable
6762
6763
6764
|
# File 'lib/syntax_tree/node.rb', line 6762
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6802
6803
6804
|
# File 'lib/syntax_tree/node.rb', line 6802
def ===(other)
other.is_a?(IVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
6773
6774
6775
|
# File 'lib/syntax_tree/node.rb', line 6773
def accept(visitor)
visitor.visit_ivar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6777
6778
6779
|
# File 'lib/syntax_tree/node.rb', line 6777
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
|
# File 'lib/syntax_tree/node.rb', line 6781
def copy(value: nil, location: nil)
node =
IVar.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
6794
6795
6796
|
# File 'lib/syntax_tree/node.rb', line 6794
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6798
6799
6800
|
# File 'lib/syntax_tree/node.rb', line 6798
def format(q)
q.text(value)
end
|