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.
- #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
2830 2831 2832 2833 2834 2835 |
# File 'lib/yarp/node.rb', line 2830 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
2827 2828 2829 |
# File 'lib/yarp/node.rb', line 2827 def closing_loc @closing_loc end |
#elements ⇒ Object (readonly)
attr_reader elements: Array
2824 2825 2826 |
# File 'lib/yarp/node.rb', line 2824 def elements @elements end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
2821 2822 2823 |
# File 'lib/yarp/node.rb', line 2821 def opening_loc @opening_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2838 2839 2840 |
# File 'lib/yarp/node.rb', line 2838 def accept(visitor) visitor.visit_hash_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2844 2845 2846 |
# File 'lib/yarp/node.rb', line 2844 def child_nodes [*elements] end |
#closing ⇒ Object
def closing: () -> String
2862 2863 2864 |
# File 'lib/yarp/node.rb', line 2862 def closing closing_loc.slice end |
#deconstruct_keys(keys) ⇒ Object
2852 2853 2854 |
# File 'lib/yarp/node.rb', line 2852 def deconstruct_keys(keys) { opening_loc: opening_loc, elements: elements, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String
2857 2858 2859 |
# File 'lib/yarp/node.rb', line 2857 def opening opening_loc.slice end |