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, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ IVar
Returns a new instance of IVar.
6827
6828
6829
6830
6831
|
# File 'lib/syntax_tree/node.rb', line 6827
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6825
6826
6827
|
# File 'lib/syntax_tree/node.rb', line 6825
def
@comments
end
|
#value ⇒ Object
- String
-
the name of the instance variable
6822
6823
6824
|
# File 'lib/syntax_tree/node.rb', line 6822
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6862
6863
6864
|
# File 'lib/syntax_tree/node.rb', line 6862
def ===(other)
other.is_a?(IVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
6833
6834
6835
|
# File 'lib/syntax_tree/node.rb', line 6833
def accept(visitor)
visitor.visit_ivar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6837
6838
6839
|
# File 'lib/syntax_tree/node.rb', line 6837
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
|
# File 'lib/syntax_tree/node.rb', line 6841
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
6854
6855
6856
|
# File 'lib/syntax_tree/node.rb', line 6854
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6858
6859
6860
|
# File 'lib/syntax_tree/node.rb', line 6858
def format(q)
q.text(value)
end
|