Class: Prism::AssocSplatNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::AssocSplatNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents a splat in a hash literal.
{ **foo }
^^^^^
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
The value to be splatted, if present.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node?, ?operator_loc: Location) -> AssocSplatNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Prism::node?, operator_loc: Location }.
-
#initialize(source, node_id, location, flags, value, operator_loc) ⇒ AssocSplatNode
constructor
Initialize a new AssocSplatNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
The location of the ‘**` operator.
-
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, value, operator_loc) ⇒ AssocSplatNode
Initialize a new AssocSplatNode node.
1317 1318 1319 1320 1321 1322 1323 1324 |
# File 'lib/prism/node.rb', line 1317 def initialize(source, node_id, location, flags, value, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @value = value @operator_loc = operator_loc end |
Instance Attribute Details
#value ⇒ Object (readonly)
The value to be splatted, if present. Will be missing when keyword rest argument forwarding is used.
{ **foo }
^^^
1365 1366 1367 |
# File 'lib/prism/node.rb', line 1365 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
1399 1400 1401 |
# File 'lib/prism/node.rb', line 1399 def self.type :assoc_splat_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
1405 1406 1407 1408 1409 |
# File 'lib/prism/node.rb', line 1405 def ===(other) other.is_a?(AssocSplatNode) && (value === other.value) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
1327 1328 1329 |
# File 'lib/prism/node.rb', line 1327 def accept(visitor) visitor.visit_assoc_splat_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
1332 1333 1334 |
# File 'lib/prism/node.rb', line 1332 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1344 1345 1346 |
# File 'lib/prism/node.rb', line 1344 def comment_targets [*value, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
1337 1338 1339 1340 1341 |
# File 'lib/prism/node.rb', line 1337 def compact_child_nodes compact = [] #: Array[Prism::node] compact << value if value compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node?, ?operator_loc: Location) -> AssocSplatNode
1349 1350 1351 |
# File 'lib/prism/node.rb', line 1349 def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, operator_loc: self.operator_loc) AssocSplatNode.new(source, node_id, location, flags, value, operator_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Prism::node?, operator_loc: Location }
1357 1358 1359 |
# File 'lib/prism/node.rb', line 1357 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
1389 1390 1391 |
# File 'lib/prism/node.rb', line 1389 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
1384 1385 1386 |
# File 'lib/prism/node.rb', line 1384 def operator operator_loc.slice end |
#operator_loc ⇒ Object
The location of the ‘**` operator.
{ **x }
^^
1371 1372 1373 1374 1375 |
# File 'lib/prism/node.rb', line 1371 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
1379 1380 1381 |
# File 'lib/prism/node.rb', line 1379 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
1394 1395 1396 |
# File 'lib/prism/node.rb', line 1394 def type :assoc_splat_node end |