class Prism::CapturePatternNode
Represents assigning to a local variable in pattern matching.
foo => [bar => baz] ^^^^^^^^^^
Represents assigning to a local variable in pattern matching.
foo => [bar => baz] ^^^^^^^^^^
Public Class Methods
(Source source, Integer node_id, Location location, Integer flags, Prism::node value, LocalVariableTargetNode target, Location operator_loc) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 6120 def initialize(source, node_id, location, flags, value, target, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @value = value @target = target @operator_loc = operator_loc end
Initialize a new CapturePatternNode node.
Initialize a new CapturePatternNode node.
: (Source source, Integer node_id, Location location, Integer flags, Prism::node value, LocalVariableTargetNode target, Location operator_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 4154
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 4077
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 4090
def inspect: () -> String
: () -> String
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 6252 def target @target end
Represents the target of the capture.
foo => bar ^^^
:call-seq: target -> LocalVariableTargetNode
Represents the target of the capture.
foo => bar ^^^
: () -> LocalVariableTargetNode
() → Prism::node
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 6235 def value @value end
Represents the value to capture.
foo => bar ^^^
:call-seq: value -> Node
Represents the value to capture.
foo => bar ^^^
: () -> Prism::node
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 6270 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Represents the Location of the => operator.
foo => bar ^^
:category: Locations :call-seq: operator_loc -> Location
Represents the Location of the => operator.
foo => bar ^^
: () -> 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 6144 def accept(visitor) visitor.visit_capture_pattern_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 6151 def child_nodes [value, target] 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 6169 def compact_child_nodes [value, target] end
(?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) → CapturePatternNode
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 6179 def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, target: self.target, operator_loc: self.operator_loc) CapturePatternNode.new(source, node_id, location, flags, value, target, operator_loc) end
Creates a copy of self with the given fields, using self as the template.
:call-seq: copy(**fields) -> CapturePatternNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) -> CapturePatternNode
() → 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 6159 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value yield target 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 6281 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end
Save the operator_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the operator_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 6293 def operator operator_loc.slice end
Slice the location of operator_loc from the source.
:call-seq: operator -> String
Slice the location of operator_loc from the source.
: () -> String