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, #pretty_print, #to_json
Constructor Details
#initialize(constant:, location:) ⇒ TopConstRef
Returns a new instance of TopConstRef.
10742
10743
10744
10745
10746
|
# File 'lib/syntax_tree/node.rb', line 10742
def initialize(constant:, location:)
@constant = constant
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10740
10741
10742
|
# File 'lib/syntax_tree/node.rb', line 10740
def
end
|
#constant ⇒ Object
- Const
-
the constant being referenced
10737
10738
10739
|
# File 'lib/syntax_tree/node.rb', line 10737
def constant
@constant
end
|
Instance Method Details
#===(other) ⇒ Object
10778
10779
10780
|
# File 'lib/syntax_tree/node.rb', line 10778
def ===(other)
other.is_a?(TopConstRef) && constant === other.constant
end
|
#accept(visitor) ⇒ Object
10748
10749
10750
|
# File 'lib/syntax_tree/node.rb', line 10748
def accept(visitor)
visitor.visit_top_const_ref(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10752
10753
10754
|
# File 'lib/syntax_tree/node.rb', line 10752
def child_nodes
[constant]
end
|
#copy(constant: nil, location: nil) ⇒ Object
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
|
# File 'lib/syntax_tree/node.rb', line 10756
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
10769
10770
10771
|
# File 'lib/syntax_tree/node.rb', line 10769
def deconstruct_keys(_keys)
{ constant: constant, location: location, comments: }
end
|
10773
10774
10775
10776
|
# File 'lib/syntax_tree/node.rb', line 10773
def format(q)
q.text("::")
q.format(constant)
end
|