class YARP::MultiWriteNode

Represents a write to a multi-target expression.

a, b, c = 1, 2, 3
^^^^^^^^^^^^^^^^^

Attributes

lparen_loc[R]

attr_reader lparen_loc: Location?

operator_loc[R]

attr_reader operator_loc: Location

rparen_loc[R]

attr_reader rparen_loc: Location?

targets[R]

attr_reader targets: Array

value[R]

attr_reader value: Node

Public Class Methods

new(targets, lparen_loc, rparen_loc, operator_loc, value, location) click to toggle source

def initialize: (targets: Array, lparen_loc: Location?, rparen_loc: Location?, operator_loc: Location, value: Node, location: Location) -> void

# File lib/yarp/node.rb, line 8342
def initialize(targets, lparen_loc, rparen_loc, operator_loc, value, location)
  @targets = targets
  @lparen_loc = lparen_loc
  @rparen_loc = rparen_loc
  @operator_loc = operator_loc
  @value = value
  @location = location
end

Public Instance Methods

accept(visitor) click to toggle source

def accept: (visitor: Visitor) -> void

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

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

# File lib/yarp/node.rb, line 8357
def child_nodes
  [*targets, value]
end
Also aliased as: deconstruct
comment_targets() click to toggle source

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

# File lib/yarp/node.rb, line 8367
def comment_targets
  [*targets, *lparen_loc, *rparen_loc, operator_loc, value]
end
compact_child_nodes() click to toggle source

def compact_child_nodes: () -> Array

# File lib/yarp/node.rb, line 8362
def compact_child_nodes
  [*targets, value]
end
copy(**params) click to toggle source

def copy: (**params) -> MultiWriteNode

# File lib/yarp/node.rb, line 8372
def copy(**params)
  MultiWriteNode.new(
    params.fetch(:targets) { targets },
    params.fetch(:lparen_loc) { lparen_loc },
    params.fetch(:rparen_loc) { rparen_loc },
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:value) { value },
    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 lib/yarp/node.rb, line 8387
def deconstruct_keys(keys)
  { targets: targets, lparen_loc: lparen_loc, rparen_loc: rparen_loc, operator_loc: operator_loc, value: value, location: location }
end
inspect(inspector = NodeInspector.new) click to toggle source
# File lib/yarp/node.rb, line 8406
def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "├── targets: #{inspector.list("#{inspector.prefix}│   ", targets)}"
  inspector << "├── lparen_loc: #{inspector.location(lparen_loc)}\n"
  inspector << "├── rparen_loc: #{inspector.location(rparen_loc)}\n"
  inspector << "├── operator_loc: #{inspector.location(operator_loc)}\n"
  inspector << "└── value:\n"
  inspector << inspector.child_node(value, "    ")
  inspector.to_str
end
lparen() click to toggle source

def lparen: () -> String?

# File lib/yarp/node.rb, line 8392
def lparen
  lparen_loc&.slice
end
operator() click to toggle source

def operator: () -> String

# File lib/yarp/node.rb, line 8402
def operator
  operator_loc.slice
end
rparen() click to toggle source

def rparen: () -> String?

# File lib/yarp/node.rb, line 8397
def rparen
  rparen_loc&.slice
end