Class: YARP::RestParameterNode

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

Overview

Represents a 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) ⇒ RestParameterNode

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



5319
5320
5321
5322
5323
# File 'lib/yarp/node.rb', line 5319

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?



5316
5317
5318
# File 'lib/yarp/node.rb', line 5316

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



5313
5314
5315
# File 'lib/yarp/node.rb', line 5313

def operator_loc
  @operator_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5326
5327
5328
# File 'lib/yarp/node.rb', line 5326

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

#child_nodesObject Also known as: deconstruct

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



5332
5333
5334
# File 'lib/yarp/node.rb', line 5332

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object

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



5340
5341
5342
# File 'lib/yarp/node.rb', line 5340

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

#nameObject

def name: () -> String?



5350
5351
5352
# File 'lib/yarp/node.rb', line 5350

def name
  name_loc&.slice
end

#operatorObject

def operator: () -> String



5345
5346
5347
# File 'lib/yarp/node.rb', line 5345

def operator
  operator_loc.slice
end