class Prism::PinnedExpressionNode - Documentation for Ruby 4.1
Description: class Prism::PinnedExpressionNode: Represents the use of the `^` operator for pinning an expression in a pattern matching expression.
Keywords: ruby,class,Prism::PinnedExpressionNode

🔍

No recent searches

# class Prism::PinnedExpressionNode

Represents the use of the `^` operator for pinning an expression in a pattern matching expression.

    foo in ^(bar)
           ^^^^^^

### Public Class Methods

new (source, node_id, location, flags, expression, operator_loc, lparen_loc, rparen_loc)
Source

    # File lib/prism/node.rb, line 24719
    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

expression → Node
Source

    # File lib/prism/node.rb, line 24826
    def expression
      @expression
    end

The expression used in the pinned expression

    foo in ^(bar)
             ^^^

## Locations

### Public Instance Methods

lparen_loc → Location
Source

    # File lib/prism/node.rb, line 24865
    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)
            ^

operator_loc → Location
Source

    # File lib/prism/node.rb, line 24840
    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)
           ^

rparen_loc → Location
Source

    # File lib/prism/node.rb, line 24890
    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

These methods are present on all subclasses of `Node`. Read the node interface docs for more information.

### Public Class Methods

type ()
Source

    # File lib/prism/node.rb, line 24806
    def self.type
      :pinned_expression_node
    end

See `Node.type`.

### Public Instance Methods

accept (visitor)
Source

    # File lib/prism/node.rb, line 24744
    def accept(visitor)
      visitor.visit_pinned_expression_node(self)
    end

See `Node.accept`.

child_nodes ()
Source

    # File lib/prism/node.rb, line 24751
    def child_nodes
      [expression]
    end

See `Node.child_nodes`.

Also aliased as: deconstruct
comment_targets ()
Source

    # File lib/prism/node.rb, line 24775
    def comment_targets
      [expression, operator_loc, lparen_loc, rparen_loc] #: Array[Prism::node | Location]
    end

See `Node.comment_targets`.

compact_child_nodes ()
Source

    # File lib/prism/node.rb, line 24768
    def compact_child_nodes
      [expression]
    end

See `Node.compact_child_nodes`.

copy(**fields) → PinnedExpressionNode
Source

    # File lib/prism/node.rb, line 24785
    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.

deconstruct ()
Alias for: child_nodes
each_child_node () { |expression| ... }
Source

    # File lib/prism/node.rb, line 24759
    def each_child_node(&blk)
      return to_enum(:each_child_node) unless block_given?

      yield expression
    end

See `Node.each_child_node`.

type ()
Source

    # File lib/prism/node.rb, line 24799
    def type
      :pinned_expression_node
    end

See `Node#type`.

## Repository

Methods related to `Relocation`.

### Public Instance Methods

save_lparen_loc (repository)
Source

    # File lib/prism/node.rb, line 24876
    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.

save_operator_loc (repository)
Source

    # File lib/prism/node.rb, line 24851
    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.

save_rparen_loc (repository)
Source

    # File lib/prism/node.rb, line 24901
    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

lparen → String
Source

    # File lib/prism/node.rb, line 24923
    def lparen
      lparen_loc.slice
    end

Slice the location of `lparen_loc` from the source.

operator → String
Source

    # File lib/prism/node.rb, line 24913
    def operator
      operator_loc.slice
    end

Slice the location of `operator_loc` from the source.

rparen → String
Source

    # File lib/prism/node.rb, line 24933
    def rparen
      rparen_loc.slice
    end

Slice the location of `rparen_loc` from the source.