Class: Backtrace

Inherits:
Object
  • Object
show all
Defined in:
lib/backtrace.rb

Overview

Backtrace as a string.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2018 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(exp, stop: '') ⇒ Backtrace

Returns a new instance of Backtrace.



30
31
32
33
# File 'lib/backtrace.rb', line 30

def initialize(exp, stop: '')
  @exp = exp
  @stop = stop
end

Instance Method Details

#to_sObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/backtrace.rb', line 35

def to_s
  [
    @exp.class.name,
    ': ',
    @exp.message,
    "\n\t",
    @exp.backtrace.reverse.drop_while { |t| !t.include?(@stop) }
      .reverse.join("\n\t")
  ].join
end