class SyntaxTree::RescueEx

RescueEx represents the list of exceptions being rescued in a rescue clause.

begin
rescue Exception => exception
end

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

exceptions[R]
nil | Node

the list of exceptions being rescued

variable[R]
nil | Field | VarField

the expression being used to capture the raised

exception

Public Class Methods

new(exceptions:, variable:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 9344
def initialize(exceptions:, variable:, location:)
  @exceptions = exceptions
  @variable = variable
  @location = location
  @comments = []
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 9396
def ===(other)
  other.is_a?(RescueEx) && exceptions === other.exceptions &&
    variable === other.variable
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 9351
def accept(visitor)
  visitor.visit_rescue_ex(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 9355
def child_nodes
  [*exceptions, variable]
end
Also aliased as: deconstruct
copy(exceptions: nil, variable: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 9359
def copy(exceptions: nil, variable: nil, location: nil)
  node =
    RescueEx.new(
      exceptions: exceptions || self.exceptions,
      variable: variable || self.variable,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 9373
def deconstruct_keys(_keys)
  {
    exceptions: exceptions,
    variable: variable,
    location: location,
    comments: comments
  }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 9382
def format(q)
  q.group do
    if exceptions
      q.text(" ")
      q.format(exceptions)
    end

    if variable
      q.text(" => ")
      q.format(variable)
    end
  end
end