Class: YARP::AssocSplatNode

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

Overview

Represents a splat in a hash literal.

{ **foo }
  ^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, operator_loc, location) ⇒ AssocSplatNode

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



372
373
374
375
376
# File 'lib/yarp/node.rb', line 372

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

Instance Attribute Details

#operator_locObject (readonly)

attr_reader operator_loc: Location



369
370
371
# File 'lib/yarp/node.rb', line 369

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node?



366
367
368
# File 'lib/yarp/node.rb', line 366

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



379
380
381
# File 'lib/yarp/node.rb', line 379

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

#child_nodesObject Also known as: deconstruct

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



385
386
387
# File 'lib/yarp/node.rb', line 385

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



393
394
395
# File 'lib/yarp/node.rb', line 393

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

#operatorObject

def operator: () -> String



398
399
400
# File 'lib/yarp/node.rb', line 398

def operator
  operator_loc.slice
end