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.
3997
3998
3999
4000
4001
|
# File 'lib/syntax_tree/node.rb', line 3997
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3995
3996
3997
|
# File 'lib/syntax_tree/node.rb', line 3995
def
@comments
end
|
#value ⇒ Object
- String
-
the name of the class variable
3992
3993
3994
|
# File 'lib/syntax_tree/node.rb', line 3992
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
4032
4033
4034
|
# File 'lib/syntax_tree/node.rb', line 4032
def ===(other)
other.is_a?(CVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
4003
4004
4005
|
# File 'lib/syntax_tree/node.rb', line 4003
def accept(visitor)
visitor.visit_cvar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
4007
4008
4009
|
# File 'lib/syntax_tree/node.rb', line 4007
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
|
# File 'lib/syntax_tree/node.rb', line 4011
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
4024
4025
4026
|
# File 'lib/syntax_tree/node.rb', line 4024
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
4028
4029
4030
|
# File 'lib/syntax_tree/node.rb', line 4028
def format(q)
q.text(value)
end
|