class SyntaxTree::ConstRef

ConstRef represents the name of the constant being used in a class or module declaration.

class Container
end

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

constant[R]
Const

the constant itself

Public Class Methods

new(constant:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 4002
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 4037
def ===(other)
  other.is_a?(ConstRef) && constant === other.constant
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 4008
def accept(visitor)
  visitor.visit_const_ref(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 4012
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 4016
def copy(constant: nil, location: nil)
  node =
    ConstRef.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 4029
def deconstruct_keys(_keys)
  { constant: constant, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 4033
def format(q)
  q.format(constant)
end