🔍

No recent searches

# class Prism::RescueModifierNode

Represents an expression modified with a rescue.

    foo rescue nil
    ^^^^^^^^^^^^^^

### Attributes

expression [R]

attr_reader expression: Prism::node

rescue_expression [R]

attr_reader `rescue_expression`: Prism::node

### Public Class Methods

new (source, node_id, location, flags, expression, keyword_loc, rescue_expression)
Source

    # File lib/prism/node.rb, line 16757
    def initialize(source, node_id, location, flags, expression, keyword_loc, rescue_expression)
      @source = source
      @node_id = node_id
      @location = location
      @flags = flags
      @expression = expression
      @keyword_loc = keyword_loc
      @rescue_expression = rescue_expression
    end

Initialize a new `RescueModifierNode` node.

type ()
Source

    # File lib/prism/node.rb, line 16843
    def self.type
      :rescue_modifier_node
    end

Return a symbol representation of this node type. See `Node::type`.

### Public Instance Methods

=== (other)
Source

    # File lib/prism/node.rb, line 16849
    def ===(other)
      other.is_a?(RescueModifierNode) &&
        (expression === other.expression) &&
        (keyword_loc.nil? == other.keyword_loc.nil?) &&
        (rescue_expression === other.rescue_expression)
    end

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

accept (visitor)
Source

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

def accept: (`Visitor` visitor) -> void

child_nodes ()
Source

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

def `child_nodes`: () -> Array

Also aliased as: deconstruct
comment_targets ()
Source

    # File lib/prism/node.rb, line 16791
    def comment_targets
      [expression, keyword_loc, rescue_expression] #: Array[Prism::node | Location]
    end

def `comment_targets`: () -> Array[Node | Location]

compact_child_nodes ()
Source

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

def `compact_child_nodes`: () -> Array

copy (node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, keyword_loc: self.keyword_loc, rescue_expression: self.rescue_expression)
Source

    # File lib/prism/node.rb, line 16796
    def copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, keyword_loc: self.keyword_loc, rescue_expression: self.rescue_expression)
      RescueModifierNode.new(source, node_id, location, flags, expression, keyword_loc, rescue_expression)
    end

def copy: (?node_id: `Integer`, ?location: `Location`, ?flags: `Integer`, ?expression: Prism::node, ?keyword_loc: `Location`, ?rescue_expression: Prism::node) -> `RescueModifierNode`

deconstruct ()

def deconstruct: () -> Array

Alias for: child_nodes
deconstruct_keys (keys)
Source

    # File lib/prism/node.rb, line 16804
    def deconstruct_keys(keys)
      { node_id: node_id, location: location, expression: expression, keyword_loc: keyword_loc, rescue_expression: rescue_expression }
    end

def `deconstruct_keys`: (Array keys) -> { node_id: `Integer`, location: `Location`, expression: Prism::node, `keyword_loc`: `Location`, `rescue_expression`: Prism::node }

each_child_node () { |expression| ... }
Source

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

      yield expression
      yield rescue_expression
    end

def `each_child_node`: () { (Prism::node) -> void } -> void | () -> Enumerator

inspect ()
Source

    # File lib/prism/node.rb, line 16833
    def inspect
      InspectVisitor.compose(self)
    end

def inspect -> `String`

keyword ()
Source

    # File lib/prism/node.rb, line 16828
    def keyword
      keyword_loc.slice
    end

def keyword: () -> `String`

keyword_loc ()
Source

    # File lib/prism/node.rb, line 16812
    def keyword_loc
      location = @keyword_loc
      return location if location.is_a?(Location)
      @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
    end

attr_reader `keyword_loc`: `Location`

save_keyword_loc (repository)
Source

    # File lib/prism/node.rb, line 16820
    def save_keyword_loc(repository)
      repository.enter(node_id, :keyword_loc)
    end

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

type ()
Source

    # File lib/prism/node.rb, line 16838
    def type
      :rescue_modifier_node
    end

Return a symbol representation of this node type. See `Node#type`.