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
70 71 72 73 74 75 |
# File 'lib/yarp/node.rb', line 70 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
61 62 63 |
# File 'lib/yarp/node.rb', line 61 def left @left end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
67 68 69 |
# File 'lib/yarp/node.rb', line 67 def operator_loc @operator_loc end |
#right ⇒ Object (readonly)
attr_reader right: Node
64 65 66 |
# File 'lib/yarp/node.rb', line 64 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
78 79 80 |
# File 'lib/yarp/node.rb', line 78 def accept(visitor) visitor.visit_alternation_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
83 84 85 |
# File 'lib/yarp/node.rb', line 83 def child_nodes [left, right] end |
#deconstruct_keys(keys) ⇒ Object
91 92 93 |
# File 'lib/yarp/node.rb', line 91 def deconstruct_keys(keys) { left: left, right: right, operator_loc: operator_loc, location: location } end |
#operator ⇒ Object
def operator: () -> String
96 97 98 |
# File 'lib/yarp/node.rb', line 96 def operator operator_loc.slice end |