class SyntaxTree::ConstPathField

ConstPathField represents the child node of some kind of assignment. It represents when you’re assigning to a constant that is being referenced as a child of another variable.

object::Const = value

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 3875
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 3919
def ===(other)
  other.is_a?(ConstPathField) && parent === other.parent &&
    constant === other.constant
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 3882
def accept(visitor)
  visitor.visit_const_path_field(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 3886
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 3890
def copy(parent: nil, constant: nil, location: nil)
  node =
    ConstPathField.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 3904
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 3913
def format(q)
  q.format(parent)
  q.text("::")
  q.format(constant)
end