Class: YARP::KeywordHashNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::KeywordHashNode
- 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
-
#elements ⇒ Object
readonly
attr_reader elements: Array.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#copy(**params) ⇒ Object
def copy: (**params) -> KeywordHashNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(elements, location) ⇒ KeywordHashNode
constructor
def initialize: (elements: Array, location: Location) -> void.
Constructor Details
#initialize(elements, location) ⇒ KeywordHashNode
def initialize: (elements: Array, location: Location) -> void
4570 4571 4572 4573 |
# File 'lib/yarp/node.rb', line 4570 def initialize(elements, location) @elements = elements @location = location end |
Instance Attribute Details
#elements ⇒ Object (readonly)
attr_reader elements: Array
4567 4568 4569 |
# File 'lib/yarp/node.rb', line 4567 def elements @elements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
4576 4577 4578 |
# File 'lib/yarp/node.rb', line 4576 def accept(visitor) visitor.visit_keyword_hash_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
4581 4582 4583 |
# File 'lib/yarp/node.rb', line 4581 def child_nodes [*elements] end |
#copy(**params) ⇒ Object
def copy: (**params) -> KeywordHashNode
4586 4587 4588 4589 4590 4591 |
# File 'lib/yarp/node.rb', line 4586 def copy(**params) KeywordHashNode.new( params.fetch(:elements) { elements }, params.fetch(:location) { location }, ) end |