class YARP::MatchWriteNode

Represents writing local variables using a regular expression match with named capture groups.

/(?<foo>bar)/ =~ baz
^^^^^^^^^^^^^^^^^^^^

Attributes

call[R]

attr_reader call: CallNode

locals[R]

attr_reader locals: Array

Public Class Methods

new(call, locals, location) click to toggle source

def initialize: (call: CallNode, locals: Array, location: Location) -> void

# File lib/yarp/node.rb, line 8035
def initialize(call, locals, location)
  @call = call
  @locals = locals
  @location = location
end

Public Instance Methods

accept(visitor) click to toggle source

def accept: (visitor: Visitor) -> void

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

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

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

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

# File lib/yarp/node.rb, line 8057
def comment_targets
  [call]
end
compact_child_nodes() click to toggle source

def compact_child_nodes: () -> Array

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

def copy: (**params) -> MatchWriteNode

# File lib/yarp/node.rb, line 8062
def copy(**params)
  MatchWriteNode.new(
    params.fetch(:call) { call },
    params.fetch(:locals) { locals },
    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 8074
def deconstruct_keys(keys)
  { call: call, locals: locals, location: location }
end
inspect(inspector = NodeInspector.new) click to toggle source
# File lib/yarp/node.rb, line 8078
def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "├── call:\n"
  inspector << inspector.child_node(call, "│   ")
  inspector << "└── locals: #{locals.inspect}\n"
  inspector.to_str
end