A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://ruby-syntax-tree.github.io/syntax_tree/SyntaxTree/Rescue.html below:

class SyntaxTree::Rescue - RDoc Documentation

  1. SyntaxTree::
  2. Rescue
class SyntaxTree::Rescue

Rescue represents the use of the rescue keyword inside of a BodyStmt node.

begin
rescue
end
Attributes
nil | Rescue

the optional next clause in the chain

nil | RescueEx

the exceptions being rescued

Statements

the expressions to evaluate when an error is rescued

Public Class Methods

Source

def initialize(keyword:, exception:, statements:, consequent:, location:)
  @keyword = keyword
  @exception = exception
  @statements = statements
  @consequent = consequent
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(Rescue) && keyword === other.keyword &&
    exception === other.exception && statements === other.statements &&
    consequent === other.consequent
end

Source

def accept(visitor)
  visitor.visit_rescue(self)
end

Source

def bind_end(end_char, end_column)
  @location =
    Location.new(
      start_line: location.start_line,
      start_char: location.start_char,
      start_column: location.start_column,
      end_line: location.end_line,
      end_char: end_char,
      end_column: end_column
    )

  if (next_node = consequent)
    next_node.bind_end(end_char, end_column)
    statements.bind_end(
      next_node.location.start_char,
      next_node.location.start_column
    )
  else
    statements.bind_end(end_char, end_column)
  end
end

Source

def child_nodes
  [keyword, exception, statements, consequent]
end

Source

def copy(
  keyword: nil,
  exception: nil,
  statements: nil,
  consequent: nil,
  location: nil
)
  node =
    Rescue.new(
      keyword: keyword || self.keyword,
      exception: exception || self.exception,
      statements: statements || self.statements,
      consequent: consequent || self.consequent,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end

Source

def deconstruct_keys(_keys)
  {
    keyword: keyword,
    exception: exception,
    statements: statements,
    consequent: consequent,
    location: location,
    comments: comments
  }
end

Source

def format(q)
  q.group do
    q.format(keyword)

    if exception
      q.nest(keyword.value.length + 1) { q.format(exception) }
    else
      q.text(" StandardError")
    end

    unless statements.empty?
      q.indent do
        q.breakable_force
        q.format(statements)
      end
    end

    if consequent
      q.breakable_force
      q.format(consequent)
    end
  end
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4