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
10716
10717
10718
10719
10720
|
# File 'lib/syntax_tree/node.rb', line 10716
def initialize(constant:, location:)
@constant = constant
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10714
10715
10716
|
# File 'lib/syntax_tree/node.rb', line 10714
def
end
|
#constant ⇒ Object
- Const
-
the constant being referenced
10711
10712
10713
|
# File 'lib/syntax_tree/node.rb', line 10711
def constant
@constant
end
|
Instance Method Details
#===(other) ⇒ Object
10752
10753
10754
|
# File 'lib/syntax_tree/node.rb', line 10752
def ===(other)
other.is_a?(TopConstRef) && constant === other.constant
end
|
#accept(visitor) ⇒ Object
10722
10723
10724
|
# File 'lib/syntax_tree/node.rb', line 10722
def accept(visitor)
visitor.visit_top_const_ref(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10726
10727
10728
|
# File 'lib/syntax_tree/node.rb', line 10726
def child_nodes
[constant]
end
|
#copy(constant: nil, location: nil) ⇒ Object
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
|
# File 'lib/syntax_tree/node.rb', line 10730
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
10743
10744
10745
|
# File 'lib/syntax_tree/node.rb', line 10743
def deconstruct_keys(_keys)
{ constant: constant, location: location, comments: }
end
|
10747
10748
10749
10750
|
# File 'lib/syntax_tree/node.rb', line 10747
def format(q)
q.text("::")
q.format(constant)
end
|