class Prism::MultiTargetNode
Represents a multi-target expression.
a, (b, c) = 1, 2, 3 ^^^^^^
Explore code sample This can be a part of MultiWriteNode as above, or the target of a for loop
for a, b in [[1, 2], [3, 4]] ^^^^
Represents a multi-target expression.
a, (b, c) = 1, 2, 3 ^^^^^^
Explore code sample This can be a part of MultiWriteNode as above, or the target of a for loop
for a, b in [[1, 2], [3, 4]] ^^^^
Public Class Methods
(Source source, Integer node_id, Location location, Integer flags, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode] lefts, (ImplicitRestNode | SplatNode)? rest, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode] rights, Location? lparen_loc, Location? rparen_loc) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 23838 def initialize(source, node_id, location, flags, lefts, rest, rights, lparen_loc, rparen_loc) @source = source @node_id = node_id @location = location @flags = flags @lefts = lefts @rest = rest @rights = rights @lparen_loc = lparen_loc @rparen_loc = rparen_loc end
Initialize a new MultiTargetNode node.
Initialize a new MultiTargetNode node.
: (Source source, Integer node_id, Location location, Integer flags, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode] lefts, (ImplicitRestNode | SplatNode)? rest, Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode] rights, Location? lparen_loc, Location? rparen_loc) -> void
Public Instance Methods
(untyped other) → boolish
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 15468
def ===: (untyped other) -> boolish
: (untyped other) -> boolish
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 15318
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 15331
def inspect: () -> String
: () -> String
() → Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 23972 def lefts @lefts end
Represents the targets expressions before a splat node.
a, (b, c, *) = 1, 2, 3, 4, 5 ^^^^
Explore code sample 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 ^^^^
:call-seq: lefts -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode]
Represents the targets expressions before a splat node.
a, (b, c, *) = 1, 2, 3, 4, 5 ^^^^
Explore code sample 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 ^^^^
: () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 24007 def rest @rest end
Represents a splat node in the target expression.
a, (b, *c) = 1, 2, 3, 4 ^^
Explore code sample The variable can be empty, this results in a SplatNode with a nil expression field.
a, (b, *) = 1, 2, 3, 4 ^
Explore code sample If the * is omitted, this field will contain an ImplicitRestNode
a, (b,) = 1, 2, 3, 4 ^
:call-seq: rest -> ImplicitRestNode | SplatNode | nil
Represents a splat node in the target expression.
a, (b, *c) = 1, 2, 3, 4 ^^
Explore code sample The variable can be empty, this results in a SplatNode with a nil expression field.
a, (b, *) = 1, 2, 3, 4 ^
Explore code sample If the * is omitted, this field will contain an ImplicitRestNode
a, (b,) = 1, 2, 3, 4 ^
: () -> (ImplicitRestNode | SplatNode)?
() → Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 24024 def rights @rights end
Represents the targets expressions after a splat node.
a, (*, b, c) = 1, 2, 3, 4, 5 ^^^^
:call-seq: rights -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode]
Represents the targets expressions after a splat node.
a, (*, b, c) = 1, 2, 3, 4, 5 ^^^^
: () -> Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode]
Locations
Public Instance Methods
() → Location?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 24042 def lparen_loc location = @lparen_loc case location when nil nil when Location location else @lparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
The Location of the opening parenthesis.
a, (b, c) = 1, 2, 3 ^
:category: Locations :call-seq: lparen_loc -> Location | nil
The Location of the opening parenthesis.
a, (b, c) = 1, 2, 3 ^
: () -> Location?
() → Location?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 24076 def rparen_loc location = @rparen_loc case location when nil nil when Location location else @rparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
The Location of the closing parenthesis.
a, (b, c) = 1, 2, 3 ^
:category: Locations :call-seq: rparen_loc -> Location | nil
The Location of the closing parenthesis.
a, (b, c) = 1, 2, 3 ^
: () -> Location?
Node Interface
These methods are present on all subclasses of Node. Read the node interface docs for more information.
Public Class Methods
Public Instance Methods
(_Visitor visitor) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 23864 def accept(visitor) visitor.visit_multi_target_node(self) end
() → Array[node?]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 23871 def child_nodes [*lefts, rest, *rights] end
() → Array[node]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 23890 def compact_child_nodes compact = [] #: Array[Prism::node] compact.concat(lefts) if (rest = self.rest); compact << rest; end compact.concat(rights) compact end
(?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode], ?lparen_loc: Location?, ?rparen_loc: Location?) → MultiTargetNode
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 23904 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) MultiTargetNode.new(source, node_id, location, flags, lefts, rest, rights, lparen_loc, rparen_loc) end
Creates a copy of self with the given fields, using self as the template.
:call-seq: copy(**fields) -> MultiTargetNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?lefts: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode], ?rest: (ImplicitRestNode | SplatNode)?, ?rights: Array[LocalVariableTargetNode | InstanceVariableTargetNode | ClassVariableTargetNode | GlobalVariableTargetNode | ConstantTargetNode | ConstantPathTargetNode | CallTargetNode | IndexTargetNode | MultiTargetNode | RequiredParameterNode], ?lparen_loc: Location?, ?rparen_loc: Location?) -> MultiTargetNode
() → Enumerator[node, void]
() { (node) → void } → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 23879 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? lefts.each { |node| yield node } if (rest = self.rest); yield rest; end rights.each { |node| yield node } end
See Node.each_child_node.
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
Repository
Methods related to Relocation.
Public Instance Methods
(_Repository repository) → Relocation::Entry?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 24059 def save_lparen_loc(repository) repository.enter(node_id, :lparen_loc) unless @lparen_loc.nil? end
Save the lparen_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the lparen_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry?
(_Repository repository) → Relocation::Entry?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 24093 def save_rparen_loc(repository) repository.enter(node_id, :rparen_loc) unless @rparen_loc.nil? end
Save the rparen_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the rparen_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry?
Slicing
Public Instance Methods
() → String?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 24104 def lparen lparen_loc&.slice end
Slice the location of lparen_loc from the source.
:call-seq: lparen -> String | nil
Slice the location of lparen_loc from the source.
: () -> String?
() → String?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 24114 def rparen rparen_loc&.slice end
Slice the location of rparen_loc from the source.
:call-seq: rparen -> String | nil
Slice the location of rparen_loc from the source.
: () -> String?