Class: YARP::ArrayPatternNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ArrayPatternNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents an array pattern in pattern matching.
foo in 1, 2
^^^^^^^^^^^
foo in [1, 2]
^^^^^^^^^^^^^
foo in *1
^^^^^^^^^
foo in Bar[]
^^^^^^^^^^^^
foo in Bar[1, 2, 3]
^^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location?.
-
#constant ⇒ Object
readonly
attr_reader constant: Node?.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location?.
-
#posts ⇒ Object
readonly
attr_reader posts: Array.
-
#requireds ⇒ Object
readonly
attr_reader requireds: Array.
-
#rest ⇒ Object
readonly
attr_reader rest: 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, requireds, rest, posts, opening_loc, closing_loc, location) ⇒ ArrayPatternNode constructor
-
#opening ⇒ Object
def opening: () -> String?.
Constructor Details
#initialize(constant, requireds, rest, posts, opening_loc, closing_loc, location) ⇒ ArrayPatternNode
268 269 270 271 272 273 274 275 276 |
# File 'lib/yarp/node.rb', line 268 def initialize(constant, requireds, rest, posts, opening_loc, closing_loc, location) @constant = constant @requireds = requireds @rest = rest @posts = posts @opening_loc = opening_loc @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location?
265 266 267 |
# File 'lib/yarp/node.rb', line 265 def closing_loc @closing_loc end |
#constant ⇒ Object (readonly)
attr_reader constant: Node?
250 251 252 |
# File 'lib/yarp/node.rb', line 250 def constant @constant end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
262 263 264 |
# File 'lib/yarp/node.rb', line 262 def opening_loc @opening_loc end |
#posts ⇒ Object (readonly)
attr_reader posts: Array
259 260 261 |
# File 'lib/yarp/node.rb', line 259 def posts @posts end |
#requireds ⇒ Object (readonly)
attr_reader requireds: Array
253 254 255 |
# File 'lib/yarp/node.rb', line 253 def requireds @requireds end |
#rest ⇒ Object (readonly)
attr_reader rest: Node?
256 257 258 |
# File 'lib/yarp/node.rb', line 256 def rest @rest end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
279 280 281 |
# File 'lib/yarp/node.rb', line 279 def accept(visitor) visitor.visit_array_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
284 285 286 |
# File 'lib/yarp/node.rb', line 284 def child_nodes [constant, *requireds, rest, *posts] end |
#closing ⇒ Object
def closing: () -> String?
302 303 304 |
# File 'lib/yarp/node.rb', line 302 def closing closing_loc&.slice end |
#deconstruct_keys(keys) ⇒ Object
292 293 294 |
# File 'lib/yarp/node.rb', line 292 def deconstruct_keys(keys) { constant: constant, requireds: requireds, rest: rest, posts: posts, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String?
297 298 299 |
# File 'lib/yarp/node.rb', line 297 def opening opening_loc&.slice end |