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) click to toggle source

Initialize a new RescueModifierNode node.

# File lib/prism/node.rb, line 15351
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
type() click to toggle source

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

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

Public Instance Methods

===(other) click to toggle source

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

# File lib/prism/node.rb, line 15435
def ===(other)
  other.is_a?(RescueModifierNode) &&
    (expression === other.expression) &&
    (keyword_loc.nil? == other.keyword_loc.nil?) &&
    (rescue_expression === other.rescue_expression)
end
accept(visitor) click to toggle source

def accept: (Visitor visitor) -> void

# File lib/prism/node.rb, line 15362
def accept(visitor)
  visitor.visit_rescue_modifier_node(self)
end
child_nodes() click to toggle source

def child_nodes: () -> Array[nil | Node]

# File lib/prism/node.rb, line 15367
def child_nodes
  [expression, rescue_expression]
end
Also aliased as: deconstruct
comment_targets() click to toggle source

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

# File lib/prism/node.rb, line 15377
def comment_targets
  [expression, keyword_loc, rescue_expression] #: Array[Prism::node | Location]
end
compact_child_nodes() click to toggle source

def compact_child_nodes: () -> Array

# File lib/prism/node.rb, line 15372
def compact_child_nodes
  [expression, rescue_expression]
end
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) click to toggle source

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

# File lib/prism/node.rb, line 15382
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
deconstruct()

def deconstruct: () -> Array[nil | Node]

Alias for: child_nodes
deconstruct_keys(keys) click to toggle source

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

# File lib/prism/node.rb, line 15390
def deconstruct_keys(keys)
  { node_id: node_id, location: location, expression: expression, keyword_loc: keyword_loc, rescue_expression: rescue_expression }
end
inspect() click to toggle source

def inspect -> String

# File lib/prism/node.rb, line 15419
def inspect
  InspectVisitor.compose(self)
end
keyword() click to toggle source

def keyword: () -> String

# File lib/prism/node.rb, line 15414
def keyword
  keyword_loc.slice
end
keyword_loc() click to toggle source

attr_reader keyword_loc: Location

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

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

# File lib/prism/node.rb, line 15406
def save_keyword_loc(repository)
  repository.enter(node_id, :keyword_loc)
end
type() click to toggle source

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

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