Class: YARP::KeywordRestParameterNode

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

Overview

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

def a(**b)
      ^^^
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operator_loc, name_loc, location) ⇒ KeywordRestParameterNode

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



4671
4672
4673
4674
4675
# File 'lib/yarp/node.rb', line 4671

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

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location?



4668
4669
4670
# File 'lib/yarp/node.rb', line 4668

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



4665
4666
4667
# File 'lib/yarp/node.rb', line 4665

def operator_loc
  @operator_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4678
4679
4680
# File 'lib/yarp/node.rb', line 4678

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

#child_nodesObject Also known as: deconstruct

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



4683
4684
4685
# File 'lib/yarp/node.rb', line 4683

def child_nodes
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> KeywordRestParameterNode



4688
4689
4690
4691
4692
4693
4694
# File 'lib/yarp/node.rb', line 4688

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

#deconstruct_keys(keys) ⇒ Object

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



4700
4701
4702
# File 'lib/yarp/node.rb', line 4700

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

#nameObject

def name: () -> String?



4710
4711
4712
# File 'lib/yarp/node.rb', line 4710

def name
  name_loc&.slice
end

#operatorObject

def operator: () -> String



4705
4706
4707
# File 'lib/yarp/node.rb', line 4705

def operator
  operator_loc.slice
end