Class: YARP::HashPatternNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::HashPatternNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a hash pattern in pattern matching.
foo => { a: 1, b: 2 }
^^^^^^^^^^^^^^
foo => { a: 1, b: 2, **c }
^^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#assocs ⇒ Object
readonly
attr_reader assocs: Array.
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location?.
-
#constant ⇒ Object
readonly
attr_reader constant: Node?.
-
#kwrest ⇒ Object
readonly
attr_reader kwrest: Node?.
-
#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(constant, assocs, kwrest, opening_loc, closing_loc, location) ⇒ HashPatternNode
constructor
def initialize: (constant: Node?, assocs: Array, kwrest: Node?, opening_loc: Location?, closing_loc: Location?, location: Location) -> void.
-
#opening ⇒ Object
def opening: () -> String?.
Constructor Details
#initialize(constant, assocs, kwrest, opening_loc, closing_loc, location) ⇒ HashPatternNode
def initialize: (constant: Node?, assocs: Array, kwrest: Node?, opening_loc: Location?, closing_loc: Location?, location: Location) -> void
2901 2902 2903 2904 2905 2906 2907 2908 |
# File 'lib/yarp/node.rb', line 2901 def initialize(constant, assocs, kwrest, opening_loc, closing_loc, location) @constant = constant @assocs = assocs @kwrest = kwrest @opening_loc = opening_loc @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#assocs ⇒ Object (readonly)
attr_reader assocs: Array
2889 2890 2891 |
# File 'lib/yarp/node.rb', line 2889 def assocs @assocs end |
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location?
2898 2899 2900 |
# File 'lib/yarp/node.rb', line 2898 def closing_loc @closing_loc end |
#constant ⇒ Object (readonly)
attr_reader constant: Node?
2886 2887 2888 |
# File 'lib/yarp/node.rb', line 2886 def constant @constant end |
#kwrest ⇒ Object (readonly)
attr_reader kwrest: Node?
2892 2893 2894 |
# File 'lib/yarp/node.rb', line 2892 def kwrest @kwrest end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
2895 2896 2897 |
# File 'lib/yarp/node.rb', line 2895 def opening_loc @opening_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2911 2912 2913 |
# File 'lib/yarp/node.rb', line 2911 def accept(visitor) visitor.visit_hash_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2916 2917 2918 |
# File 'lib/yarp/node.rb', line 2916 def child_nodes [constant, *assocs, kwrest] end |
#closing ⇒ Object
def closing: () -> String?
2934 2935 2936 |
# File 'lib/yarp/node.rb', line 2934 def closing closing_loc&.slice end |
#deconstruct_keys(keys) ⇒ Object
2924 2925 2926 |
# File 'lib/yarp/node.rb', line 2924 def deconstruct_keys(keys) { constant: constant, assocs: assocs, kwrest: kwrest, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String?
2929 2930 2931 |
# File 'lib/yarp/node.rb', line 2929 def opening opening_loc&.slice end |