Class: YARP::ArrayNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ArrayNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i.
[1, 2, 3]
^^^^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location?.
-
#elements ⇒ Object
readonly
attr_reader elements: Array.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location?.
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(elements, opening_loc, closing_loc, location) ⇒ ArrayNode
constructor
def initialize: (elements: Array, opening_loc: Location?, closing_loc: Location?, location: Location) -> void.
-
#opening ⇒ Object
def opening: () -> String?.
Constructor Details
#initialize(elements, opening_loc, closing_loc, location) ⇒ ArrayNode
def initialize: (elements: Array, opening_loc: Location?, closing_loc: Location?, location: Location) -> void
200 201 202 203 204 205 |
# File 'lib/yarp/node.rb', line 200 def initialize(elements, opening_loc, closing_loc, location) @elements = elements @opening_loc = opening_loc @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location?
197 198 199 |
# File 'lib/yarp/node.rb', line 197 def closing_loc @closing_loc end |
#elements ⇒ Object (readonly)
attr_reader elements: Array
191 192 193 |
# File 'lib/yarp/node.rb', line 191 def elements @elements end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
194 195 196 |
# File 'lib/yarp/node.rb', line 194 def opening_loc @opening_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
208 209 210 |
# File 'lib/yarp/node.rb', line 208 def accept(visitor) visitor.visit_array_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
214 215 216 |
# File 'lib/yarp/node.rb', line 214 def child_nodes [*elements] end |
#closing ⇒ Object
def closing: () -> String?
232 233 234 |
# File 'lib/yarp/node.rb', line 232 def closing closing_loc&.slice end |
#deconstruct_keys(keys) ⇒ Object
222 223 224 |
# File 'lib/yarp/node.rb', line 222 def deconstruct_keys(keys) { elements: elements, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end |
#opening ⇒ Object
def opening: () -> String?
227 228 229 |
# File 'lib/yarp/node.rb', line 227 def opening opening_loc&.slice end |