Class: Riml::BacktraceFilter
- Inherits:
-
Object
- Object
- Riml::BacktraceFilter
- Includes:
- Environment
- Defined in:
- lib/riml/backtrace_filter.rb
Constant Summary collapse
- RIML_INTERNAL_FILE_REGEX =
/#{ROOTDIR}/
Constants included from Environment
Environment::BINDIR, Environment::LIBDIR, Environment::ROOTDIR
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #filter!(first_i = 0, last_i = -1)) ⇒ Object
-
#initialize(error) ⇒ BacktraceFilter
constructor
A new instance of BacktraceFilter.
Constructor Details
#initialize(error) ⇒ BacktraceFilter
Returns a new instance of BacktraceFilter.
11 12 13 |
# File 'lib/riml/backtrace_filter.rb', line 11 def initialize(error) @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
9 10 11 |
# File 'lib/riml/backtrace_filter.rb', line 9 def error @error end |
Instance Method Details
#filter!(first_i = 0, last_i = -1)) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/riml/backtrace_filter.rb', line 15 def filter!(first_i = 0, last_i = -1) if first_i < 0 raise ArgumentError, "first argument must be >= 0" end if last_i > 0 && first_i > last_i raise ArgumentError, "first index must come before (or be equal to) last index" end # check if `responds_to?(:debug)` because we don't want to have to # require 'riml.rb' just for this unless Riml.respond_to?(:debug) && Riml.debug add_to_head = @error.backtrace[0...first_i] || [] add_to_tail = @error.backtrace[last_i...-1] || [] backtrace = @error.backtrace[first_i..last_i] || [] backtrace.delete_if { |loc| RIML_INTERNAL_FILE_REGEX =~ loc } @error.set_backtrace(add_to_head + backtrace + add_to_tail) end end |