Class: YARP::AssocNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::AssocNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a hash key/value pair.
{ a => b }
^^^^^^
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
attr_reader key: Node.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location?.
-
#value ⇒ Object
readonly
attr_reader value: Node?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(key, value, operator_loc, location) ⇒ AssocNode
constructor
def initialize: (key: Node, value: Node?, operator_loc: Location?, location: Location) -> void.
-
#operator ⇒ Object
def operator: () -> String?.
Constructor Details
#initialize(key, value, operator_loc, location) ⇒ AssocNode
def initialize: (key: Node, value: Node?, operator_loc: Location?, location: Location) -> void
328 329 330 331 332 333 |
# File 'lib/yarp/node.rb', line 328 def initialize(key, value, operator_loc, location) @key = key @value = value @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#key ⇒ Object (readonly)
attr_reader key: Node
319 320 321 |
# File 'lib/yarp/node.rb', line 319 def key @key end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location?
325 326 327 |
# File 'lib/yarp/node.rb', line 325 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node?
322 323 324 |
# File 'lib/yarp/node.rb', line 322 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
336 337 338 |
# File 'lib/yarp/node.rb', line 336 def accept(visitor) visitor.visit_assoc_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
342 343 344 |
# File 'lib/yarp/node.rb', line 342 def child_nodes [key, value] end |
#deconstruct_keys(keys) ⇒ Object
350 351 352 |
# File 'lib/yarp/node.rb', line 350 def deconstruct_keys(keys) { key: key, value: value, operator_loc: operator_loc, location: location } end |
#operator ⇒ Object
def operator: () -> String?
355 356 357 |
# File 'lib/yarp/node.rb', line 355 def operator operator_loc&.slice end |