Class: YARP::BlockArgumentNode

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

Overview

Represents block method arguments.

bar(&args)
^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression, operator_loc, location) ⇒ BlockArgumentNode

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



605
606
607
608
609
# File 'lib/yarp/node.rb', line 605

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

Instance Attribute Details

#expressionObject (readonly)

attr_reader expression: Node?



599
600
601
# File 'lib/yarp/node.rb', line 599

def expression
  @expression
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



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

def operator_loc
  @operator_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



617
618
619
# File 'lib/yarp/node.rb', line 617

def child_nodes
  [expression]
end

#copy(**params) ⇒ Object

def copy: (**params) -> BlockArgumentNode



622
623
624
625
626
627
628
# File 'lib/yarp/node.rb', line 622

def copy(**params)
  BlockArgumentNode.new(
    params.fetch(:expression) { expression },
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



634
635
636
# File 'lib/yarp/node.rb', line 634

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

#operatorObject

def operator: () -> String



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

def operator
  operator_loc.slice
end