Class: SyntaxTree::TopConstRef
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::TopConstRef
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
TopConstRef is very similar to TopConstField except that it is not involved in an assignment.
::Constant
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(constant:, location:) ⇒ TopConstRef
Returns a new instance of TopConstRef.
10835
10836
10837
10838
10839
|
# File 'lib/syntax_tree/node.rb', line 10835
def initialize(constant:, location:)
@constant = constant
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10833
10834
10835
|
# File 'lib/syntax_tree/node.rb', line 10833
def
@comments
end
|
#constant ⇒ Object
- Const
-
the constant being referenced
10830
10831
10832
|
# File 'lib/syntax_tree/node.rb', line 10830
def constant
@constant
end
|
Instance Method Details
#===(other) ⇒ Object
10871
10872
10873
|
# File 'lib/syntax_tree/node.rb', line 10871
def ===(other)
other.is_a?(TopConstRef) && constant === other.constant
end
|
#accept(visitor) ⇒ Object
10841
10842
10843
|
# File 'lib/syntax_tree/node.rb', line 10841
def accept(visitor)
visitor.visit_top_const_ref(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10845
10846
10847
|
# File 'lib/syntax_tree/node.rb', line 10845
def child_nodes
[constant]
end
|
#copy(constant: nil, location: nil) ⇒ Object
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
|
# File 'lib/syntax_tree/node.rb', line 10849
def copy(constant: nil, location: nil)
node =
TopConstRef.new(
constant: constant || self.constant,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
10862
10863
10864
|
# File 'lib/syntax_tree/node.rb', line 10862
def deconstruct_keys(_keys)
{ constant: constant, location: location, comments: }
end
|
10866
10867
10868
10869
|
# File 'lib/syntax_tree/node.rb', line 10866
def format(q)
q.text("::")
q.format(constant)
end
|