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.
4006
4007
4008
4009
4010
|
# File 'lib/syntax_tree/node.rb', line 4006
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
4004
4005
4006
|
# File 'lib/syntax_tree/node.rb', line 4004
def
end
|
#value ⇒ Object
- String
-
the name of the class variable
4001
4002
4003
|
# File 'lib/syntax_tree/node.rb', line 4001
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
4041
4042
4043
|
# File 'lib/syntax_tree/node.rb', line 4041
def ===(other)
other.is_a?(CVar) && value === other.value
end
|
#accept(visitor) ⇒ Object
4012
4013
4014
|
# File 'lib/syntax_tree/node.rb', line 4012
def accept(visitor)
visitor.visit_cvar(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
4016
4017
4018
|
# File 'lib/syntax_tree/node.rb', line 4016
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
|
# File 'lib/syntax_tree/node.rb', line 4020
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
4033
4034
4035
|
# File 'lib/syntax_tree/node.rb', line 4033
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
4037
4038
4039
|
# File 'lib/syntax_tree/node.rb', line 4037
def format(q)
q.text(value)
end
|