Class: YARP::CapturePatternNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::CapturePatternNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents assigning to a local variable in pattern matching.
foo => [bar => baz]
^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#target ⇒ Object
readonly
attr_reader target: Node.
-
#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(value, target, operator_loc, location) ⇒ CapturePatternNode
constructor
def initialize: (value: Node, target: Node, operator_loc: Location, location: Location) -> void.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(value, target, operator_loc, location) ⇒ CapturePatternNode
def initialize: (value: Node, target: Node, operator_loc: Location, location: Location) -> void
1018 1019 1020 1021 1022 1023 |
# File 'lib/yarp/node.rb', line 1018 def initialize(value, target, operator_loc, location) @value = value @target = target @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
1015 1016 1017 |
# File 'lib/yarp/node.rb', line 1015 def operator_loc @operator_loc end |
#target ⇒ Object (readonly)
attr_reader target: Node
1012 1013 1014 |
# File 'lib/yarp/node.rb', line 1012 def target @target end |
#value ⇒ Object (readonly)
attr_reader value: Node
1009 1010 1011 |
# File 'lib/yarp/node.rb', line 1009 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1026 1027 1028 |
# File 'lib/yarp/node.rb', line 1026 def accept(visitor) visitor.visit_capture_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1032 1033 1034 |
# File 'lib/yarp/node.rb', line 1032 def child_nodes [value, target] end |
#deconstruct_keys(keys) ⇒ Object
1040 1041 1042 |
# File 'lib/yarp/node.rb', line 1040 def deconstruct_keys(keys) { value: value, target: target, operator_loc: operator_loc, location: location } end |
#operator ⇒ Object
def operator: () -> String
1045 1046 1047 |
# File 'lib/yarp/node.rb', line 1045 def operator operator_loc.slice end |