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[nil | Node].
-
#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.
-
#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.
1104 1105 1106 1107 1108 1109 1110 1111 |
# File 'lib/prism/node.rb', line 1104 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 }
^^^
1152 1153 1154 |
# File 'lib/prism/node.rb', line 1152 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
1180 1181 1182 |
# File 'lib/prism/node.rb', line 1180 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.
1186 1187 1188 1189 1190 |
# File 'lib/prism/node.rb', line 1186 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
1114 1115 1116 |
# File 'lib/prism/node.rb', line 1114 def accept(visitor) visitor.visit_assoc_splat_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1119 1120 1121 |
# File 'lib/prism/node.rb', line 1119 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1131 1132 1133 |
# File 'lib/prism/node.rb', line 1131 def comment_targets [*value, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
1124 1125 1126 1127 1128 |
# File 'lib/prism/node.rb', line 1124 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
1136 1137 1138 |
# File 'lib/prism/node.rb', line 1136 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 }
1144 1145 1146 |
# File 'lib/prism/node.rb', line 1144 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
1170 1171 1172 |
# File 'lib/prism/node.rb', line 1170 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
1165 1166 1167 |
# File 'lib/prism/node.rb', line 1165 def operator operator_loc.slice end |
#operator_loc ⇒ Object
The location of the ‘**` operator.
{ **x }
^^
1158 1159 1160 1161 1162 |
# File 'lib/prism/node.rb', line 1158 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
1175 1176 1177 |
# File 'lib/prism/node.rb', line 1175 def type :assoc_splat_node end |