class Prism::PinnedExpressionNode
Represents the use of the ^ operator for pinning an expression in a pattern matching expression.
foo in ^(bar)
^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 19829 def initialize(source, node_id, location, flags, expression, operator_loc, lparen_loc, rparen_loc) @source = source @node_id = node_id @location = location @flags = flags @expression = expression @operator_loc = operator_loc @lparen_loc = lparen_loc @rparen_loc = rparen_loc end
Initialize a new PinnedExpressionNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 19915 def expression @expression end
The expression used in the pinned expression
foo in ^(bar)
^^^
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 19948 def lparen_loc location = @lparen_loc return location if location.is_a?(Location) @lparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
The Location of the opening parenthesis.
foo in ^(bar)
^
Source
# File lib/prism/node.rb, line 19927 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)
^
Source
# File lib/prism/node.rb, line 19969 def rparen_loc location = @rparen_loc return location if location.is_a?(Location) @rparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
The Location of the closing parenthesis.
foo in ^(bar)
^
Node Interface
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 19852 def accept(visitor) visitor.visit_pinned_expression_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 19857 def child_nodes [expression] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 19874 def comment_targets [expression, operator_loc, lparen_loc, rparen_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 19869 def compact_child_nodes [expression] end
Source
# File lib/prism/node.rb, line 19882 def copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, operator_loc: self.operator_loc, lparen_loc: self.lparen_loc, rparen_loc: self.rparen_loc) PinnedExpressionNode.new(source, node_id, location, flags, expression, operator_loc, lparen_loc, rparen_loc) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 19862 def each_child_node return to_enum(:each_child_node) unless block_given? yield expression end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 19957 def save_lparen_loc(repository) repository.enter(node_id, :lparen_loc) end
Save the lparen_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 19936 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.
Source
# File lib/prism/node.rb, line 19978 def save_rparen_loc(repository) repository.enter(node_id, :rparen_loc) end
Save the rparen_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 19996 def lparen lparen_loc.slice end
Slice the location of lparen_loc from the source.
Source
# File lib/prism/node.rb, line 19988 def operator operator_loc.slice end
Slice the location of operator_loc from the source.
Source
# File lib/prism/node.rb, line 20004 def rparen rparen_loc.slice end
Slice the location of rparen_loc from the source.