class SyntaxTree::TopConstRef

TopConstRef is very similar to TopConstField except that it is not involved in an assignment.

::Constant

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

constant[R]
Const

the constant being referenced

Public Class Methods

new(constant:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 10883
def initialize(constant:, location:)
  @constant = constant
  @location = location
  @comments = []
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 10919
def ===(other)
  other.is_a?(TopConstRef) && constant === other.constant
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 10889
def accept(visitor)
  visitor.visit_top_const_ref(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 10893
def child_nodes
  [constant]
end
Also aliased as: deconstruct
copy(constant: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 10897
def copy(constant: nil, location: nil)
  node =
    TopConstRef.new(
      constant: constant || self.constant,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 10910
def deconstruct_keys(_keys)
  { constant: constant, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 10914
def format(q)
  q.text("::")
  q.format(constant)
end