Class: PrettyTrace::StructuredBacktrace
- Inherits:
-
Object
- Object
- PrettyTrace::StructuredBacktrace
- Defined in:
- lib/pretty_trace/structured_backtrace.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #formatted_backtrace ⇒ Object
-
#initialize(backtrace, options = {}) ⇒ StructuredBacktrace
constructor
A new instance of StructuredBacktrace.
- #structure ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(backtrace, options = {}) ⇒ StructuredBacktrace
Returns a new instance of StructuredBacktrace.
5 6 7 8 |
# File 'lib/pretty_trace/structured_backtrace.rb', line 5 def initialize(backtrace, = {}) @options = @backtrace = backtrace end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
3 4 5 |
# File 'lib/pretty_trace/structured_backtrace.rb', line 3 def backtrace @backtrace end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/pretty_trace/structured_backtrace.rb', line 3 def @options end |
Instance Method Details
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/pretty_trace/structured_backtrace.rb', line 29 def empty? formatted_backtrace.empty? end |
#formatted_backtrace ⇒ Object
21 22 23 |
# File 'lib/pretty_trace/structured_backtrace.rb', line 21 def formatted_backtrace structure.map(&:formatted_line) end |
#structure ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pretty_trace/structured_backtrace.rb', line 10 def structure result = backtrace_list.map { |line| BacktraceItem.new line } result = if should_trim? result result.group_by(&:path).flat_map { |_, items| [items.first, items.last].uniq } else result end should_reverse? ? result.reverse : result end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/pretty_trace/structured_backtrace.rb', line 25 def to_s formatted_backtrace.join "\n" end |