Class: YARP::LocalVariableTargetNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents writing to a local variable in a context that doesn’t have an explicit value.

foo, bar = baz
^^^  ^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, depth, location) ⇒ LocalVariableTargetNode

def initialize: (name: Symbol, depth: Integer, location: Location) -> void



5054
5055
5056
5057
5058
# File 'lib/yarp/node.rb', line 5054

def initialize(name, depth, location)
  @name = name
  @depth = depth
  @location = location
end

Instance Attribute Details

#depthObject (readonly)

attr_reader depth: Integer



5051
5052
5053
# File 'lib/yarp/node.rb', line 5051

def depth
  @depth
end

#nameObject (readonly)

attr_reader name: Symbol



5048
5049
5050
# File 'lib/yarp/node.rb', line 5048

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5061
5062
5063
# File 'lib/yarp/node.rb', line 5061

def accept(visitor)
  visitor.visit_local_variable_target_node(self)
end

#child_nodesObject Also known as: deconstruct

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



5066
5067
5068
# File 'lib/yarp/node.rb', line 5066

def child_nodes
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> LocalVariableTargetNode



5071
5072
5073
5074
5075
5076
5077
# File 'lib/yarp/node.rb', line 5071

def copy(**params)
  LocalVariableTargetNode.new(
    params.fetch(:name) { name },
    params.fetch(:depth) { depth },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



5083
5084
5085
# File 'lib/yarp/node.rb', line 5083

def deconstruct_keys(keys)
  { name: name, depth: depth, location: location }
end