1. Prism::
  2. CapturePatternNode

class Prism::CapturePatternNode

Represents assigning to a local variable in pattern matching.

foo => [bar => baz]       ^^^^^^^^^^^^

Attributes

target[R]

Represents the target of the capture.

foo => bar^^^
value[R]

Represents the value to capture.

foo => bar       ^^^

Public Class Methods

Source
# File lib/prism/node.rb, line 3461definitialize(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_locend

Initialize a newCapturePatternNode node.

Source
# File lib/prism/node.rb, line 3548defself.type:capture_pattern_nodeend

Return a symbol representation of this node type. SeeNode::type.

Public Instance Methods

Source
# File lib/prism/node.rb, line 3554def===(other)other.is_a?(CapturePatternNode)&&    (value===other.value)&&    (target===other.target)&&    (operator_loc.nil?==other.operator_loc.nil?)end

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.

Source
# File lib/prism/node.rb, line 3472defaccept(visitor)visitor.visit_capture_pattern_node(self)end

def accept: (Visitor visitor) -> void

Source
# File lib/prism/node.rb, line 3477defchild_nodes  [value,target]end

defchild_nodes: () ->Array

Also aliased as:deconstruct
Source
# File lib/prism/node.rb, line 3487defcomment_targets  [value,target,operator_loc]#: Array[Prism::node | Location]end

defcomment_targets: () -> Array[Node | Location]

Source
# File lib/prism/node.rb, line 3482defcompact_child_nodes  [value,target]end

defcompact_child_nodes: () ->Array

Source
# File lib/prism/node.rb, line 3492defcopy(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

def copy: (?node_id:Integer, ?location:Location, ?flags:Integer, ?value: Prism::node, ?target:LocalVariableTargetNode, ?operator_loc:Location) ->CapturePatternNode

def deconstruct: () ->Array

Alias for:child_nodes
Source
# File lib/prism/node.rb, line 3500defdeconstruct_keys(keys)  {node_id:node_id,location:location,value:value,target:target,operator_loc:operator_loc }end

defdeconstruct_keys: (Array keys) -> { node_id:Integer, location:Location, value: Prism::node, target:LocalVariableTargetNode,operator_loc:Location }

Source
# File lib/prism/node.rb, line 3538definspectInspectVisitor.compose(self)end

def inspect ->String

Source
# File lib/prism/node.rb, line 3533defoperatoroperator_loc.sliceend

def operator: () ->String

Source
# File lib/prism/node.rb, line 3520defoperator_loclocation =@operator_locreturnlocationiflocation.is_a?(Location)@operator_loc =Location.new(source,location>>32,location&0xFFFFFFFF)end

Represents the location of the=> operator.

foo => bar    ^^
Source
# File lib/prism/node.rb, line 3528defsave_operator_loc(repository)repository.enter(node_id,:operator_loc)end

Save theoperator_loc location using the given saved source so that it can be retrieved later.

Source
# File lib/prism/node.rb, line 3543deftype:capture_pattern_nodeend

Return a symbol representation of this node type. SeeNode#type.