Class: SyntaxTree::CVar
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::CVar
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
CVar represents the use of a class variable.
@@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:) ⇒ CVar
Returns a new instance of CVar.
3972
3973
3974
3975
3976
|
# File 'lib/syntax_tree/node.rb', line 3972
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3970
3971
3972
|
# File 'lib/syntax_tree/node.rb', line 3970
def
end
|
#value ⇒ Object
- String
-
the name of the class variable
3967
3968
3969
|
# File 'lib/syntax_tree/node.rb', line 3967
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
4007
4008
4009
|
# File 'lib/syntax_tree/node.rb', line 4007
def ===(other)
other.is_a?(CVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
3978
3979
3980
|
# File 'lib/syntax_tree/node.rb', line 3978
def accept(visitor)
visitor.visit_cvar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
3982
3983
3984
|
# File 'lib/syntax_tree/node.rb', line 3982
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
|
# File 'lib/syntax_tree/node.rb', line 3986
def copy(value: nil, location: nil)
node =
CVar.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
3999
4000
4001
|
# File 'lib/syntax_tree/node.rb', line 3999
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
4003
4004
4005
|
# File 'lib/syntax_tree/node.rb', line 4003
def format(q)
q.text(value)
end
|