class YARP::ConstantPathTargetNode

Represents writing to a constant path in a context that doesn’t have an explicit value.

Foo::Foo, Bar::Bar = baz
^^^^^^^^  ^^^^^^^^

Attributes

child[R]

attr_reader child: Node

delimiter_loc[R]

attr_reader delimiter_loc: Location

parent[R]

attr_reader parent: Node?

Public Class Methods

new(parent, child, delimiter_loc, location) click to toggle source

def initialize: (parent: Node?, child: Node, delimiter_loc: Location, location: Location) -> void

# File yarp/node.rb, line 3154
def initialize(parent, child, delimiter_loc, location)
  @parent = parent
  @child = child
  @delimiter_loc = delimiter_loc
  @location = location
end

Public Instance Methods

accept(visitor) click to toggle source

def accept: (visitor: Visitor) -> void

# File yarp/node.rb, line 3162
def accept(visitor)
  visitor.visit_constant_path_target_node(self)
end
child_nodes() click to toggle source

def child_nodes: () -> Array[nil | Node]

# File yarp/node.rb, line 3167
def child_nodes
  [parent, child]
end
Also aliased as: deconstruct
comment_targets() click to toggle source

def comment_targets: () -> Array[Node | Location]

# File yarp/node.rb, line 3172
def comment_targets
  [*parent, child, delimiter_loc]
end
copy(**params) click to toggle source

def copy: (**params) -> ConstantPathTargetNode

# File yarp/node.rb, line 3177
def copy(**params)
  ConstantPathTargetNode.new(
    params.fetch(:parent) { parent },
    params.fetch(:child) { child },
    params.fetch(:delimiter_loc) { delimiter_loc },
    params.fetch(:location) { location },
  )
end
deconstruct()

def deconstruct: () -> Array[nil | Node]

Alias for: child_nodes
deconstruct_keys(keys) click to toggle source

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]

# File yarp/node.rb, line 3190
def deconstruct_keys(keys)
  { parent: parent, child: child, delimiter_loc: delimiter_loc, location: location }
end
delimiter() click to toggle source

def delimiter: () -> String

# File yarp/node.rb, line 3195
def delimiter
  delimiter_loc.slice
end
inspect(inspector = NodeInspector.new) click to toggle source
# File yarp/node.rb, line 3199
def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  if (parent = self.parent).nil?
    inspector << "├── parent: ∅\n"
  else
    inspector << "├── parent:\n"
    inspector << parent.inspect(inspector.child_inspector("│   ")).delete_prefix(inspector.prefix)
  end
  inspector << "├── child:\n"
  inspector << inspector.child_node(child, "│   ")
  inspector << "└── delimiter_loc: #{inspector.location(delimiter_loc)}\n"
  inspector.to_str
end