Class: YARP::LocalVariableReadNode

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

Overview

Represents reading a local variable. Note that this requires that a local variable of the same name has already been written to in the same scope, otherwise it is parsed as a method call.

foo
^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(constant_id, depth, location) ⇒ LocalVariableReadNode

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



3949
3950
3951
3952
3953
# File 'lib/yarp/node.rb', line 3949

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

Instance Attribute Details

#constant_idObject (readonly)

attr_reader constant_id: Symbol



3943
3944
3945
# File 'lib/yarp/node.rb', line 3943

def constant_id
  @constant_id
end

#depthObject (readonly)

attr_reader depth: Integer



3946
3947
3948
# File 'lib/yarp/node.rb', line 3946

def depth
  @depth
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3956
3957
3958
# File 'lib/yarp/node.rb', line 3956

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

#child_nodesObject Also known as: deconstruct

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



3962
3963
3964
# File 'lib/yarp/node.rb', line 3962

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object

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



3970
3971
3972
# File 'lib/yarp/node.rb', line 3970

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