Class: YARP::BlockLocalVariableNode

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

Overview

Represents a block local variable.

a { |; b| }
       ^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, location) ⇒ BlockLocalVariableNode

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



847
848
849
850
# File 'lib/yarp/node.rb', line 847

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

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



844
845
846
# File 'lib/yarp/node.rb', line 844

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



853
854
855
# File 'lib/yarp/node.rb', line 853

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

#child_nodesObject Also known as: deconstruct

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



858
859
860
# File 'lib/yarp/node.rb', line 858

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



863
864
865
# File 'lib/yarp/node.rb', line 863

def comment_targets
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> BlockLocalVariableNode



868
869
870
871
872
873
# File 'lib/yarp/node.rb', line 868

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



879
880
881
# File 'lib/yarp/node.rb', line 879

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

#inspect(inspector = NodeInspector.new) ⇒ Object



883
884
885
886
887
# File 'lib/yarp/node.rb', line 883

def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "└── name: #{name.inspect}\n"
  inspector.to_str
end