Class: YARP::FindPatternNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::FindPatternNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a find pattern in pattern matching.
foo in *bar, baz, *qux
^^^^^^^^^^^^^^^^^^^^^^
foo in [*bar, baz, *qux]
^^^^^^^^^^^^^^^^^^^^^^^^
foo in Foo(*bar, baz, *qux)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location?.
-
#constant ⇒ Object
readonly
attr_reader constant: Node?.
-
#left ⇒ Object
readonly
attr_reader left: Node.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location?.
-
#requireds ⇒ Object
readonly
attr_reader requireds: Array.
-
#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].
-
#closing ⇒ Object
def closing: () -> String?.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(constant, left, requireds, right, opening_loc, closing_loc, location) ⇒ FindPatternNode
constructor
def initialize: (constant: Node?, left: Node, requireds: Array, right: Node, opening_loc: Location?, closing_loc: Location?, location: Location) -> void.
-
#opening ⇒ Object
def opening: () -> String?.
Constructor Details
#initialize(constant, left, requireds, right, opening_loc, closing_loc, location) ⇒ FindPatternNode
def initialize: (constant: Node?, left: Node, requireds: Array, right: Node, opening_loc: Location?, closing_loc: Location?, location: Location) -> void
2300 2301 2302 2303 2304 2305 2306 2307 2308 |
# File 'lib/yarp/node.rb', line 2300 def initialize(constant, left, requireds, right, opening_loc, closing_loc, location) @constant = constant @left = left @requireds = requireds @right = right @opening_loc = opening_loc @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location?
2297 2298 2299 |
# File 'lib/yarp/node.rb', line 2297 def closing_loc @closing_loc end |
#constant ⇒ Object (readonly)
attr_reader constant: Node?
2282 2283 2284 |
# File 'lib/yarp/node.rb', line 2282 def constant @constant end |
#left ⇒ Object (readonly)
attr_reader left: Node
2285 2286 2287 |
# File 'lib/yarp/node.rb', line 2285 def left @left end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
2294 2295 2296 |
# File 'lib/yarp/node.rb', line 2294 def opening_loc @opening_loc end |
#requireds ⇒ Object (readonly)
attr_reader requireds: Array
2288 2289 2290 |
# File 'lib/yarp/node.rb', line 2288 def requireds @requireds end |
#right ⇒ Object (readonly)
attr_reader right: Node
2291 2292 2293 |
# File 'lib/yarp/node.rb', line 2291 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2311 2312 2313 |
# File 'lib/yarp/node.rb', line 2311 def accept(visitor) visitor.visit_find_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2316 2317 2318 |
# File 'lib/yarp/node.rb', line 2316 def child_nodes [constant, left, *requireds, right] end |
#closing ⇒ Object
def closing: () -> String?
2334 2335 2336 |
# File 'lib/yarp/node.rb', line 2334 def closing closing_loc&.slice end |
#deconstruct_keys(keys) ⇒ Object
2324 2325 2326 |
# File 'lib/yarp/node.rb', line 2324 def deconstruct_keys(keys) { constant: constant, left: left, requireds: requireds, right: right, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String?
2329 2330 2331 |
# File 'lib/yarp/node.rb', line 2329 def opening opening_loc&.slice end |