Class: YARP::LocalVariableReadNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::LocalVariableReadNode
- 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
-
#depth ⇒ Object
readonly
attr_reader depth: Integer.
-
#name ⇒ Object
readonly
attr_reader name: Symbol.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> LocalVariableReadNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, depth, location) ⇒ LocalVariableReadNode
constructor
def initialize: (name: Symbol, depth: Integer, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
Constructor Details
#initialize(name, depth, location) ⇒ LocalVariableReadNode
def initialize: (name: Symbol, depth: Integer, location: Location) -> void
6711 6712 6713 6714 6715 |
# File 'lib/yarp/node.rb', line 6711 def initialize(name, depth, location) @name = name @depth = depth @location = location end |
Instance Attribute Details
#depth ⇒ Object (readonly)
attr_reader depth: Integer
6708 6709 6710 |
# File 'lib/yarp/node.rb', line 6708 def depth @depth end |
#name ⇒ Object (readonly)
attr_reader name: Symbol
6705 6706 6707 |
# File 'lib/yarp/node.rb', line 6705 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
6718 6719 6720 |
# File 'lib/yarp/node.rb', line 6718 def accept(visitor) visitor.visit_local_variable_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
6723 6724 6725 |
# File 'lib/yarp/node.rb', line 6723 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6728 6729 6730 |
# File 'lib/yarp/node.rb', line 6728 def comment_targets [] end |
#copy(**params) ⇒ Object
def copy: (**params) -> LocalVariableReadNode
6733 6734 6735 6736 6737 6738 6739 |
# File 'lib/yarp/node.rb', line 6733 def copy(**params) LocalVariableReadNode.new( params.fetch(:name) { name }, params.fetch(:depth) { depth }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
6745 6746 6747 |
# File 'lib/yarp/node.rb', line 6745 def deconstruct_keys(keys) { name: name, depth: depth, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
6749 6750 6751 6752 6753 6754 |
# File 'lib/yarp/node.rb', line 6749 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── name: #{name.inspect}\n" inspector << "└── depth: #{depth.inspect}\n" inspector.to_str end |