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



607
608
609
610
611
# File 'lib/yarp/node.rb', line 607

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?



601
602
603
# File 'lib/yarp/node.rb', line 601

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



604
605
606
# File 'lib/yarp/node.rb', line 604

def operator_loc
  @operator_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



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

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object

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



627
628
629
# File 'lib/yarp/node.rb', line 627

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

#nameObject

def name: () -> String?



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

def name
  name_loc&.slice
end

#operatorObject

def operator: () -> String



637
638
639
# File 'lib/yarp/node.rb', line 637

def operator
  operator_loc.slice
end