class Prism::PinnedVariableNode
Represents the use of the ^ operator for pinning a variable in a pattern matching expression.
foo in ^bar
^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 20025 def initialize(source, node_id, location, flags, variable, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @variable = variable @operator_loc = operator_loc end
Initialize a new PinnedVariableNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 20109 def variable @variable end
The variable used in the pinned expression
foo in ^bar
^^^
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 20121 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
The Location of the ^ operator
foo in ^bar
^
Node Interface
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 20046 def accept(visitor) visitor.visit_pinned_variable_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 20051 def child_nodes [variable] end
See Node.child_nodes.
Also aliased as: deconstruct
Source
# File lib/prism/node.rb, line 20068 def comment_targets [variable, operator_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 20063 def compact_child_nodes [variable] end
Source
# File lib/prism/node.rb, line 20076 def copy(node_id: self.node_id, location: self.location, flags: self.flags, variable: self.variable, operator_loc: self.operator_loc) PinnedVariableNode.new(source, node_id, location, flags, variable, operator_loc) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 20056 def each_child_node return to_enum(:each_child_node) unless block_given? yield variable end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 20130 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.
Slicing
Public Instance Methods
Source
# File lib/prism/node.rb, line 20140 def operator operator_loc.slice end
Slice the location of operator_loc from the source.