Class: SyntaxTree::ConstRef
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::ConstRef
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
ConstRef represents the name of the constant being used in a class or module declaration.
class Container
end
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(constant:, location:) ⇒ ConstRef
3955
3956
3957
3958
3959
|
# File 'lib/syntax_tree/node.rb', line 3955
def initialize(constant:, location:)
@constant = constant
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3953
3954
3955
|
# File 'lib/syntax_tree/node.rb', line 3953
def
@comments
end
|
#constant ⇒ Object
- Const
-
the constant itself
3950
3951
3952
|
# File 'lib/syntax_tree/node.rb', line 3950
def constant
@constant
end
|
Instance Method Details
#===(other) ⇒ Object
3990
3991
3992
|
# File 'lib/syntax_tree/node.rb', line 3990
def ===(other)
other.is_a?(ConstRef) && constant === other.constant
end
|
#accept(visitor) ⇒ Object
3961
3962
3963
|
# File 'lib/syntax_tree/node.rb', line 3961
def accept(visitor)
visitor.visit_const_ref(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
3965
3966
3967
|
# File 'lib/syntax_tree/node.rb', line 3965
def child_nodes
[constant]
end
|
#copy(constant: nil, location: nil) ⇒ Object
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
|
# File 'lib/syntax_tree/node.rb', line 3969
def copy(constant: nil, location: nil)
node =
ConstRef.new(
constant: constant || self.constant,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
3982
3983
3984
|
# File 'lib/syntax_tree/node.rb', line 3982
def deconstruct_keys(_keys)
{ constant: constant, location: location, comments: }
end
|
3986
3987
3988
|
# File 'lib/syntax_tree/node.rb', line 3986
def format(q)
q.format(constant)
end
|