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 => | 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].
-
#copy(**params) ⇒ Object
def copy: (**params) -> AlternationPatternNode.
- #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
80 81 82 83 84 85 |
# File 'lib/yarp/node.rb', line 80 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
71 72 73 |
# File 'lib/yarp/node.rb', line 71 def left @left end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
77 78 79 |
# File 'lib/yarp/node.rb', line 77 def operator_loc @operator_loc end |
#right ⇒ Object (readonly)
attr_reader right: Node
74 75 76 |
# File 'lib/yarp/node.rb', line 74 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
88 89 90 |
# File 'lib/yarp/node.rb', line 88 def accept(visitor) visitor.visit_alternation_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
93 94 95 |
# File 'lib/yarp/node.rb', line 93 def child_nodes [left, right] end |
#copy(**params) ⇒ Object
def copy: (**params) -> AlternationPatternNode
98 99 100 101 102 103 104 105 |
# File 'lib/yarp/node.rb', line 98 def copy(**params) AlternationPatternNode.new( params.fetch(:left) { left }, params.fetch(:right) { right }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
111 112 113 |
# File 'lib/yarp/node.rb', line 111 def deconstruct_keys(keys) { left: left, right: right, operator_loc: operator_loc, location: location } end |
#operator ⇒ Object
def operator: () -> String
116 117 118 |
# File 'lib/yarp/node.rb', line 116 def operator operator_loc.slice end |