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.



8754
8755
8756
8757
8758
# File 'lib/syntax_tree/node.rb', line 8754

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



8752
8753
8754
# File 'lib/syntax_tree/node.rb', line 8752

def comments
  @comments
end

#constantObject (readonly)

Const

the constant being referenced



8749
8750
8751
# File 'lib/syntax_tree/node.rb', line 8749

def constant
  @constant
end

Instance Method Details

#accept(visitor) ⇒ Object



8760
8761
8762
# File 'lib/syntax_tree/node.rb', line 8760

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

#child_nodesObject Also known as: deconstruct



8764
8765
8766
# File 'lib/syntax_tree/node.rb', line 8764

def child_nodes
  [constant]
end

#deconstruct_keys(_keys) ⇒ Object



8770
8771
8772
# File 'lib/syntax_tree/node.rb', line 8770

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

#format(q) ⇒ Object



8774
8775
8776
8777
# File 'lib/syntax_tree/node.rb', line 8774

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