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
2841 2842 2843 2844 2845 2846 |
# File 'lib/yarp/node.rb', line 2841 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
2838 2839 2840 |
# File 'lib/yarp/node.rb', line 2838 def closing_loc @closing_loc end |
#elements ⇒ Object (readonly)
attr_reader elements: Array
2835 2836 2837 |
# File 'lib/yarp/node.rb', line 2835 def elements @elements end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
2832 2833 2834 |
# File 'lib/yarp/node.rb', line 2832 def opening_loc @opening_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2849 2850 2851 |
# File 'lib/yarp/node.rb', line 2849 def accept(visitor) visitor.visit_hash_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2854 2855 2856 |
# File 'lib/yarp/node.rb', line 2854 def child_nodes [*elements] end |
#closing ⇒ Object
def closing: () -> String
2872 2873 2874 |
# File 'lib/yarp/node.rb', line 2872 def closing closing_loc.slice end |
#deconstruct_keys(keys) ⇒ Object
2862 2863 2864 |
# File 'lib/yarp/node.rb', line 2862 def deconstruct_keys(keys) { opening_loc: opening_loc, elements: elements, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String
2867 2868 2869 |
# File 'lib/yarp/node.rb', line 2867 def opening opening_loc.slice end |