Class: PowerTrace::Stack
- Inherits:
-
Object
- Object
- PowerTrace::Stack
- Includes:
- Enumerable
- Defined in:
- lib/power_trace/stack.rb
Constant Summary collapse
- OUTPUT_OPTIONS_DEFAULT =
{ colorize: true, line_limit: 100, extra_info_indent: 4 }
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(options = {}) ⇒ Stack
constructor
A new instance of Stack.
- #to_backtrace(output_options = {}) ⇒ Object
- #to_s(output_options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Stack
Returns a new instance of Stack.
16 17 18 19 20 |
# File 'lib/power_trace/stack.rb', line 16 def initialize( = {}) @options = @exception = .fetch(:exception, false) @entries = extract_entries.compact end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
8 9 10 |
# File 'lib/power_trace/stack.rb', line 8 def entries @entries end |
Instance Method Details
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/power_trace/stack.rb', line 22 def each(&block) @entries.each(&block) end |
#empty? ⇒ Boolean
36 37 38 |
# File 'lib/power_trace/stack.rb', line 36 def empty? @entries.empty? end |
#to_backtrace(output_options = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/power_trace/stack.rb', line 26 def to_backtrace( = {}) [:colorize] = .fetch(:colorize, PowerTrace.colorize_backtrace) if @exception = () @entries.map { |e| e.to_s() } end |
#to_s(output_options = {}) ⇒ Object
32 33 34 |
# File 'lib/power_trace/stack.rb', line 32 def to_s( = {}) to_backtrace().join("\n") end |