Class: SyntaxTree::TopConstRef

Inherits:
Node
  • Object
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:, comments: []) ⇒ TopConstRef

Returns a new instance of TopConstRef.



8788
8789
8790
8791
8792
# File 'lib/syntax_tree/node.rb', line 8788

def initialize(constant:, location:, comments: [])
  @constant = constant
  @location = location
  @comments = comments
end

Instance Attribute Details

#comments ⇒ Object (readonly)

[Array[ Comment | EmbDoc ]] the comments attached to this node



8786
8787
8788
# File 'lib/syntax_tree/node.rb', line 8786

def comments
  @comments
end

#constant ⇒ Object (readonly)

[Const] the constant being referenced



8783
8784
8785
# File 'lib/syntax_tree/node.rb', line 8783

def constant
  @constant
end

Instance Method Details

#accept(visitor) ⇒ Object



8794
8795
8796
# File 'lib/syntax_tree/node.rb', line 8794

def accept(visitor)
  visitor.visit_top_const_ref(self)
end

#child_nodes ⇒ Object Also known as: deconstruct



8798
8799
8800
# File 'lib/syntax_tree/node.rb', line 8798

def child_nodes
  [constant]
end

#deconstruct_keys(_keys) ⇒ Object



8804
8805
8806
# File 'lib/syntax_tree/node.rb', line 8804

def deconstruct_keys(_keys)
  { constant: constant, location: location, comments: comments }
end

#format(q) ⇒ Object



8808
8809
8810
8811
# File 'lib/syntax_tree/node.rb', line 8808

def format(q)
  q.text("::")
  q.format(constant)
end