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(name, depth, location) ⇒ LocalVariableReadNode

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



5008
5009
5010
5011
5012
# File 'lib/yarp/node.rb', line 5008

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

Instance Attribute Details

#depthObject (readonly)

attr_reader depth: Integer



5005
5006
5007
# File 'lib/yarp/node.rb', line 5005

def depth
  @depth
end

#nameObject (readonly)

attr_reader name: Symbol



5002
5003
5004
# File 'lib/yarp/node.rb', line 5002

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5015
5016
5017
# File 'lib/yarp/node.rb', line 5015

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

#child_nodesObject Also known as: deconstruct

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



5020
5021
5022
# File 'lib/yarp/node.rb', line 5020

def child_nodes
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> LocalVariableReadNode



5025
5026
5027
5028
5029
5030
5031
# File 'lib/yarp/node.rb', line 5025

def copy(**params)
  LocalVariableReadNode.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]



5037
5038
5039
# File 'lib/yarp/node.rb', line 5037

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