Class: YARP::HashNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::HashNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a hash literal.
{ a => b }
^^^^^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location.
-
#elements ⇒ Object
readonly
attr_reader elements: Array.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing ⇒ Object
def closing: () -> String.
-
#copy(**params) ⇒ Object
def copy: (**params) -> HashNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(opening_loc, elements, closing_loc, location) ⇒ HashNode
constructor
def initialize: (opening_loc: Location, elements: Array, closing_loc: Location, location: Location) -> void.
-
#opening ⇒ Object
def opening: () -> String.
Constructor Details
#initialize(opening_loc, elements, closing_loc, location) ⇒ HashNode
def initialize: (opening_loc: Location, elements: Array, closing_loc: Location, location: Location) -> void
3585 3586 3587 3588 3589 3590 |
# File 'lib/yarp/node.rb', line 3585 def initialize(opening_loc, elements, closing_loc, location) @opening_loc = opening_loc @elements = elements @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location
3582 3583 3584 |
# File 'lib/yarp/node.rb', line 3582 def closing_loc @closing_loc end |
#elements ⇒ Object (readonly)
attr_reader elements: Array
3579 3580 3581 |
# File 'lib/yarp/node.rb', line 3579 def elements @elements end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
3576 3577 3578 |
# File 'lib/yarp/node.rb', line 3576 def opening_loc @opening_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
3593 3594 3595 |
# File 'lib/yarp/node.rb', line 3593 def accept(visitor) visitor.visit_hash_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
3598 3599 3600 |
# File 'lib/yarp/node.rb', line 3598 def child_nodes [*elements] end |
#closing ⇒ Object
def closing: () -> String
3626 3627 3628 |
# File 'lib/yarp/node.rb', line 3626 def closing closing_loc.slice end |
#copy(**params) ⇒ Object
def copy: (**params) -> HashNode
3603 3604 3605 3606 3607 3608 3609 3610 |
# File 'lib/yarp/node.rb', line 3603 def copy(**params) HashNode.new( params.fetch(:opening_loc) { opening_loc }, params.fetch(:elements) { elements }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
3616 3617 3618 |
# File 'lib/yarp/node.rb', line 3616 def deconstruct_keys(keys) { opening_loc: opening_loc, elements: elements, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String
3621 3622 3623 |
# File 'lib/yarp/node.rb', line 3621 def opening opening_loc.slice end |