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

#pretty_print, #to_json

Constructor Details

#initialize(constant:, location:, comments: []) ⇒ TopConstRef

Returns a new instance of TopConstRef.



8028
8029
8030
8031
8032
# File 'lib/syntax_tree/node.rb', line 8028

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



8026
8027
8028
# File 'lib/syntax_tree/node.rb', line 8026

def comments
  @comments
end

#constantObject (readonly)

Const

the constant being referenced



8023
8024
8025
# File 'lib/syntax_tree/node.rb', line 8023

def constant
  @constant
end

Instance Method Details

#accept(visitor) ⇒ Object



8034
8035
8036
# File 'lib/syntax_tree/node.rb', line 8034

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

#child_nodesObject Also known as: deconstruct



8038
8039
8040
# File 'lib/syntax_tree/node.rb', line 8038

def child_nodes
  [constant]
end

#deconstruct_keys(keys) ⇒ Object



8044
8045
8046
# File 'lib/syntax_tree/node.rb', line 8044

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

#format(q) ⇒ Object



8048
8049
8050
8051
# File 'lib/syntax_tree/node.rb', line 8048

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