Class: Prism::MultiWriteNode
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
PrismNode
|
|
|
Instance Chain:
self,
PrismNode
|
|
| Inherits: |
PrismNode
|
| Defined in: | lib/prism/node.rb, ext/prism/api_node.c |
Overview
Represents a write to a multi-target expression.
a, b, c = 1, 2, 3
^^^^^^^^^^^^^^^^^
Class Method Summary
-
.new(source, node_id, location, flags, lefts, rest, rights, lparen_loc, rparen_loc, operator_loc, value) ⇒ MultiWriteNode
constructor
Initialize a new
MultiWriteNodenode. -
.type
Return a symbol representation of this node type.
Instance Attribute Summary
Instance Method Summary
-
#===(other)
Implements case-equality for the node.
-
#accept(visitor)
def accept: (Visitor visitor) -> void.
-
#child_nodes
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, lefts: self.lefts, rest: self.rest, rights: self.rights, lparen_loc: self.lparen_loc, rparen_loc: self.rparen_loc, operator_loc: self.operator_loc, value: self.value)
def copy: (?node_id: Integer, ?location:
Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode |InstanceVariableTargetNode|ClassVariableTargetNode|GlobalVariableTargetNode|ConstantTargetNode|ConstantPathTargetNode|CallTargetNode|IndexTargetNode| MultiTargetNode], ?rest:ImplicitRestNode|SplatNode| nil, ?rights: Array[LocalVariableTargetNode |InstanceVariableTargetNode|ClassVariableTargetNode|GlobalVariableTargetNode|ConstantTargetNode|ConstantPathTargetNode|CallTargetNode|IndexTargetNode| MultiTargetNode], ?lparen_loc: Location?, ?rparen_loc: Location?, ?operator_loc:Location, ?value:Prism.node) ->MultiWriteNode. -
#deconstruct
Alias for #child_nodes.
-
#deconstruct_keys(keys)
def deconstruct_keys: (Array keys) -> { node_id: Integer, location:
Location, lefts: Array[LocalVariableTargetNode |InstanceVariableTargetNode|ClassVariableTargetNode|GlobalVariableTargetNode|ConstantTargetNode|ConstantPathTargetNode|CallTargetNode|IndexTargetNode| MultiTargetNode], rest:ImplicitRestNode|SplatNode| nil, rights: Array[LocalVariableTargetNode |InstanceVariableTargetNode|ClassVariableTargetNode|GlobalVariableTargetNode|ConstantTargetNode|ConstantPathTargetNode|CallTargetNode|IndexTargetNode| MultiTargetNode], lparen_loc: Location?, rparen_loc: Location?, operator_loc:Location, value:Prism.node} -
#inspect
def inspect -> String.
-
#lparen
def lparen: () -> String?
-
#lparen_loc
The location of the opening parenthesis.
-
#operator
def operator: () -> String.
-
#operator_loc
The location of the operator.
-
#rparen
def rparen: () -> String?
-
#rparen_loc
The location of the closing parenthesis.
-
#type
Return a symbol representation of this node type.
Constructor Details
.new(source, node_id, location, flags, lefts, rest, rights, lparen_loc, rparen_loc, operator_loc, value) ⇒ MultiWriteNode
Initialize a new MultiWriteNode node.
# File 'lib/prism/node.rb', line 11617
def initialize(source, node_id, location, flags, lefts, rest, rights, lparen_loc, rparen_loc, operator_loc, value) @source = source @node_id = node_id @location = location @flags = flags @lefts = lefts @rest = rest @rights = rights @lparen_loc = lparen_loc @rparen_loc = rparen_loc @operator_loc = operator_loc @value = value end
Class Method Details
.type
Return a symbol representation of this node type. See Node::type.
# File 'lib/prism/node.rb', line 11772
def self.type :multi_write_node end
Instance Attribute Details
#lefts (readonly)
Represents the targets expressions before a splat node.
a, b, * = 1, 2, 3, 4, 5
^^^^
The splat node can be absent, in that case all target expressions are in the left field.
a, b, c = 1, 2, 3, 4, 5
^^^^^^^
# File 'lib/prism/node.rb', line 11678
attr_reader :lefts
#rest (readonly)
Represents a splat node in the target expression.
a, b, *c = 1, 2, 3, 4
^^
The variable can be empty, this results in a SplatNode with a nil expression field.
a, b, * = 1, 2, 3, 4
^
If the * is omitted, the field will containt an ImplicitRestNode
a, b, = 1, 2, 3, 4
^
# File 'lib/prism/node.rb', line 11693
attr_reader :rest
#rights (readonly)
Represents the targets expressions after a splat node.
a, *, b, c = 1, 2, 3, 4, 5
^^^^
# File 'lib/prism/node.rb', line 11698
attr_reader :rights
#value (readonly)
The value to write to the targets. It can be anynon-void expression.
a, b, c = 1, 2, 3
^^^^^^^
# File 'lib/prism/node.rb', line 11745
attr_reader :value
Instance Method Details
#===(other)
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
# File 'lib/prism/node.rb', line 11778
def ===(other) other.is_a?(MultiWriteNode) && (lefts.length == other.lefts.length) && lefts.zip(other.lefts).all? { |left, right| left === right } && (rest === other.rest) && (rights.length == other.rights.length) && rights.zip(other.rights).all? { |left, right| left === right } && (lparen_loc.nil? == other.lparen_loc.nil?) && (rparen_loc.nil? == other.rparen_loc.nil?) && (operator_loc.nil? == other.operator_loc.nil?) && (value === other.value) end
#accept(visitor)
def accept: (Visitor visitor) -> void
# File 'lib/prism/node.rb', line 11632
def accept(visitor) visitor.visit_multi_write_node(self) end
#child_nodes Also known as: #deconstruct
def child_nodes: () -> Array[nil | Node]
#comment_targets
def comment_targets: () -> Array[Node | Location]
# File 'lib/prism/node.rb', line 11652
def comment_targets [*lefts, *rest, *rights, *lparen_loc, *rparen_loc, operator_loc, value] #: Array[Prism::node | Location] end
#compact_child_nodes
def compact_child_nodes: () -> Array
#copy(node_id: self.node_id, location: self.location, flags: self.flags, lefts: self.lefts, rest: self.rest, rights: self.rights, lparen_loc: self.lparen_loc, rparen_loc: self.rparen_loc, operator_loc: self.operator_loc, value: self.value)
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode], ?rest: ImplicitRestNode | SplatNode | nil, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode], ?lparen_loc: Location?, ?rparen_loc: Location?, ?operator_loc: Location, ?value: Prism.node) -> MultiWriteNode
# File 'lib/prism/node.rb', line 11657
def copy(node_id: self.node_id, location: self.location, flags: self.flags, lefts: self.lefts, rest: self.rest, rights: self.rights, lparen_loc: self.lparen_loc, rparen_loc: self.rparen_loc, operator_loc: self.operator_loc, value: self.value) MultiWriteNode.new(source, node_id, location, flags, lefts, rest, rights, lparen_loc, rparen_loc, operator_loc, value) end
#deconstruct
Alias for #child_nodes.
# File 'lib/prism/node.rb', line 11662
alias deconstruct child_nodes
#deconstruct_keys(keys)
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode], rest: ImplicitRestNode | SplatNode | nil, rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode], lparen_loc: Location?, rparen_loc: Location?, operator_loc: Location, value: Prism.node }
# File 'lib/prism/node.rb', line 11665
def deconstruct_keys(keys) { node_id: node_id, location: location, lefts: lefts, rest: rest, rights: rights, lparen_loc: lparen_loc, rparen_loc: rparen_loc, operator_loc: operator_loc, value: value } end
#inspect
def inspect -> String
# File 'lib/prism/node.rb', line 11762
def inspect InspectVisitor.compose(self) end
#lparen
def lparen: () -> String?
# File 'lib/prism/node.rb', line 11747
def lparen lparen_loc&.slice end
#lparen_loc
The location of the opening parenthesis.
(a, b, c) = 1, 2, 3
^
#operator
def operator: () -> String
# File 'lib/prism/node.rb', line 11757
def operator operator_loc.slice end
#operator_loc
The location of the operator.
a, b, c = 1, 2, 3
^
#rparen
def rparen: () -> String?
# File 'lib/prism/node.rb', line 11752
def rparen rparen_loc&.slice end
#rparen_loc
The location of the closing parenthesis.
(a, b, c) = 1, 2, 3
^
#type
Return a symbol representation of this node type. See Node#type.
# File 'lib/prism/node.rb', line 11767
def type :multi_write_node end