Class: YARP::InstanceVariableTargetNode

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

Overview

Represents writing to an instance 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, location) ⇒ InstanceVariableTargetNode

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



4123
4124
4125
4126
# File 'lib/yarp/node.rb', line 4123

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

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



4120
4121
4122
# File 'lib/yarp/node.rb', line 4120

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4129
4130
4131
# File 'lib/yarp/node.rb', line 4129

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

#child_nodesObject Also known as: deconstruct

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



4134
4135
4136
# File 'lib/yarp/node.rb', line 4134

def child_nodes
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> InstanceVariableTargetNode



4139
4140
4141
4142
4143
4144
# File 'lib/yarp/node.rb', line 4139

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

#deconstruct_keys(keys) ⇒ Object

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



4150
4151
4152
# File 'lib/yarp/node.rb', line 4150

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