class SyntaxTree::ConstPathRef

ConstPathRef represents referencing a constant by a path.

object::Const

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

constant[R]
Const

the constant itself

parent[R]
Node

the source of the constant

Public Class Methods

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

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 3983
def ===(other)
  other.is_a?(ConstPathRef) && parent === other.parent &&
    constant === other.constant
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 3946
def accept(visitor)
  visitor.visit_const_path_ref(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 3950
def child_nodes
  [parent, constant]
end
Also aliased as: deconstruct
copy(parent: nil, constant: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 3954
def copy(parent: nil, constant: nil, location: nil)
  node =
    ConstPathRef.new(
      parent: parent || self.parent,
      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 3968
def deconstruct_keys(_keys)
  {
    parent: parent,
    constant: constant,
    location: location,
    comments: comments
  }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 3977
def format(q)
  q.format(parent)
  q.text("::")
  q.format(constant)
end