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
2333 2334 2335 2336 2337 2338 2339 2340 2341 |
# File 'lib/yarp/node.rb', line 2333 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?
2330 2331 2332 |
# File 'lib/yarp/node.rb', line 2330 def closing_loc @closing_loc end |
#constant ⇒ Object (readonly)
attr_reader constant: Node?
2315 2316 2317 |
# File 'lib/yarp/node.rb', line 2315 def constant @constant end |
#left ⇒ Object (readonly)
attr_reader left: Node
2318 2319 2320 |
# File 'lib/yarp/node.rb', line 2318 def left @left end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
2327 2328 2329 |
# File 'lib/yarp/node.rb', line 2327 def opening_loc @opening_loc end |
#requireds ⇒ Object (readonly)
attr_reader requireds: Array
2321 2322 2323 |
# File 'lib/yarp/node.rb', line 2321 def requireds @requireds end |
#right ⇒ Object (readonly)
attr_reader right: Node
2324 2325 2326 |
# File 'lib/yarp/node.rb', line 2324 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2344 2345 2346 |
# File 'lib/yarp/node.rb', line 2344 def accept(visitor) visitor.visit_find_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2350 2351 2352 |
# File 'lib/yarp/node.rb', line 2350 def child_nodes [constant, left, *requireds, right] end |
#closing ⇒ Object
def closing: () -> String?
2368 2369 2370 |
# File 'lib/yarp/node.rb', line 2368 def closing closing_loc&.slice end |
#deconstruct_keys(keys) ⇒ Object
2358 2359 2360 |
# File 'lib/yarp/node.rb', line 2358 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?
2363 2364 2365 |
# File 'lib/yarp/node.rb', line 2363 def opening opening_loc&.slice end |