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 => [ => 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
1010 1011 1012 1013 1014 1015 |
# File 'lib/yarp/node.rb', line 1010 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
1007 1008 1009 |
# File 'lib/yarp/node.rb', line 1007 def operator_loc @operator_loc end |
#target ⇒ Object (readonly)
attr_reader target: Node
1004 1005 1006 |
# File 'lib/yarp/node.rb', line 1004 def target @target end |
#value ⇒ Object (readonly)
attr_reader value: Node
1001 1002 1003 |
# File 'lib/yarp/node.rb', line 1001 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1018 1019 1020 |
# File 'lib/yarp/node.rb', line 1018 def accept(visitor) visitor.visit_capture_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1023 1024 1025 |
# File 'lib/yarp/node.rb', line 1023 def child_nodes [value, target] end |
#deconstruct_keys(keys) ⇒ Object
1031 1032 1033 |
# File 'lib/yarp/node.rb', line 1031 def deconstruct_keys(keys) { value: value, target: target, operator_loc: operator_loc, location: location } end |
#operator ⇒ Object
def operator: () -> String
1036 1037 1038 |
# File 'lib/yarp/node.rb', line 1036 def operator operator_loc.slice end |