Class: YARP::AlternationPatternNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::AlternationPatternNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents an alternation pattern in pattern matching.
foo => bar | baz
^^^^^^^^^
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
attr_reader left: Node.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#right ⇒ Object
readonly
attr_reader right: 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(left, right, operator_loc, location) ⇒ AlternationPatternNode
constructor
def initialize: (left: Node, right: Node, operator_loc: Location, location: Location) -> void.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(left, right, operator_loc, location) ⇒ AlternationPatternNode
def initialize: (left: Node, right: Node, operator_loc: Location, location: Location) -> void
71 72 73 74 75 76 |
# File 'lib/yarp/node.rb', line 71 def initialize(left, right, operator_loc, location) @left = left @right = right @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#left ⇒ Object (readonly)
attr_reader left: Node
62 63 64 |
# File 'lib/yarp/node.rb', line 62 def left @left end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
68 69 70 |
# File 'lib/yarp/node.rb', line 68 def operator_loc @operator_loc end |
#right ⇒ Object (readonly)
attr_reader right: Node
65 66 67 |
# File 'lib/yarp/node.rb', line 65 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
79 80 81 |
# File 'lib/yarp/node.rb', line 79 def accept(visitor) visitor.visit_alternation_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
85 86 87 |
# File 'lib/yarp/node.rb', line 85 def child_nodes [left, right] end |
#deconstruct_keys(keys) ⇒ Object
93 94 95 |
# File 'lib/yarp/node.rb', line 93 def deconstruct_keys(keys) { left: left, right: right, operator_loc: operator_loc, location: location } end |
#operator ⇒ Object
def operator: () -> String
98 99 100 |
# File 'lib/yarp/node.rb', line 98 def operator operator_loc.slice end |