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.
6885
6886
6887
6888
6889
|
# File 'lib/syntax_tree/node.rb', line 6885
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6883
6884
6885
|
# File 'lib/syntax_tree/node.rb', line 6883
def
@comments
end
|
#value ⇒ Object
- String
-
the name of the instance variable
6880
6881
6882
|
# File 'lib/syntax_tree/node.rb', line 6880
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6920
6921
6922
|
# File 'lib/syntax_tree/node.rb', line 6920
def ===(other)
other.is_a?(IVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
6891
6892
6893
|
# File 'lib/syntax_tree/node.rb', line 6891
def accept(visitor)
visitor.visit_ivar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6895
6896
6897
|
# File 'lib/syntax_tree/node.rb', line 6895
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
|
# File 'lib/syntax_tree/node.rb', line 6899
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
6912
6913
6914
|
# File 'lib/syntax_tree/node.rb', line 6912
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6916
6917
6918
|
# File 'lib/syntax_tree/node.rb', line 6916
def format(q)
q.text(value)
end
|