Class: YARP::KeywordHashNode

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

Overview

Represents a hash literal without opening and closing braces.

foo(a: b)
    ^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elements, location) ⇒ KeywordHashNode

def initialize: (elements: Array, location: Location) -> void



3590
3591
3592
3593
# File 'lib/yarp/node.rb', line 3590

def initialize(elements, location)
  @elements = elements
  @location = location
end

Instance Attribute Details

#elementsObject (readonly)

attr_reader elements: Array



3587
3588
3589
# File 'lib/yarp/node.rb', line 3587

def elements
  @elements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3596
3597
3598
# File 'lib/yarp/node.rb', line 3596

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

#child_nodesObject Also known as: deconstruct

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



3602
3603
3604
# File 'lib/yarp/node.rb', line 3602

def child_nodes
  [*elements]
end

#deconstruct_keys(keys) ⇒ Object

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



3610
3611
3612
# File 'lib/yarp/node.rb', line 3610

def deconstruct_keys(keys)
  { elements: elements, location: location }
end