Class: MetaRuby::GUI::ExceptionRendering::BacktraceParser

Inherits:
Object
  • Object
show all
Defined in:
lib/metaruby/gui/exception_rendering.rb

Overview

Shim class that parses a backtrace into its constituents

This is an internal class, that should not be used directly. Use parse_backtrace instead.

It provides the methods required for facet’s #call_stack method to work, thus allowing to use it to parse an arbitrary backtrace

Instance Method Summary collapse

Constructor Details

#initialize(backtrace) ⇒ BacktraceParser

Create a parser for the given backtrace



100
101
102
# File 'lib/metaruby/gui/exception_rendering.rb', line 100

def initialize(backtrace)
    @backtrace = backtrace || []
end

Instance Method Details

#parseArray<(String,Integer,String)>

Parse the backtrace into file, line and method

Returns:

  • (Array<(String,Integer,String)>)


107
108
109
# File 'lib/metaruby/gui/exception_rendering.rb', line 107

def parse
    call_stack(0)
end

#pp_call_stack(level) ⇒ Object

Returns the backtrace

This is required by facet’s #call_stack



121
122
123
# File 'lib/metaruby/gui/exception_rendering.rb', line 121

def pp_call_stack(level)
    @backtrace[level..-1]
end

#pp_callstack(level) ⇒ Object

Returns the backtrace

This is required by facet’s #call_stack



114
115
116
# File 'lib/metaruby/gui/exception_rendering.rb', line 114

def pp_callstack(level)
    @backtrace[level..-1]
end