Class: YARP::BlockParameterNode

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

Overview

Represents a block parameter to a method, block, or lambda definition.

def a(&b)
      ^^
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_loc, operator_loc, location) ⇒ BlockParameterNode

def initialize: (name_loc: Location?, operator_loc: Location, location: Location) -> void



618
619
620
621
622
# File 'lib/yarp/node.rb', line 618

def initialize(name_loc, operator_loc, location)
  @name_loc = name_loc
  @operator_loc = operator_loc
  @location = location
end

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location?



612
613
614
# File 'lib/yarp/node.rb', line 612

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



615
616
617
# File 'lib/yarp/node.rb', line 615

def operator_loc
  @operator_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



625
626
627
# File 'lib/yarp/node.rb', line 625

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

#child_nodesObject Also known as: deconstruct

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



631
632
633
# File 'lib/yarp/node.rb', line 631

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object

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



639
640
641
# File 'lib/yarp/node.rb', line 639

def deconstruct_keys(keys)
  { name_loc: name_loc, operator_loc: operator_loc, location: location }
end

#nameObject

def name: () -> String?



644
645
646
# File 'lib/yarp/node.rb', line 644

def name
  name_loc&.slice
end

#operatorObject

def operator: () -> String



649
650
651
# File 'lib/yarp/node.rb', line 649

def operator
  operator_loc.slice
end