Class: Logue::Stack
- Inherits:
-
Object
- Object
- Logue::Stack
- Defined in:
- lib/logue/stack.rb
Instance Attribute Summary collapse
-
#frames ⇒ Object
readonly
Returns the value of attribute frames.
Instance Method Summary collapse
- #filtered ⇒ Object
-
#initialize(depth: 2) ⇒ Stack
constructor
A new instance of Stack.
Constructor Details
#initialize(depth: 2) ⇒ Stack
Returns a new instance of Stack.
10 11 12 13 14 15 16 17 |
# File 'lib/logue/stack.rb', line 10 def initialize depth: 2 # caller_locations requires Ruby 2.0+ locations = caller_locations depth @frames = locations.collect do |loc| # no absolute_path from "(eval)" Frame.new path: loc.absolute_path || loc.path, line: loc.lineno, method: loc.label end end |
Instance Attribute Details
#frames ⇒ Object (readonly)
Returns the value of attribute frames.
8 9 10 |
# File 'lib/logue/stack.rb', line 8 def frames @frames end |
Instance Method Details
#filtered ⇒ Object
19 20 21 22 23 |
# File 'lib/logue/stack.rb', line 19 def filtered re = Regexp.new 'logue.*/lib/logue' logframe = @frames.rindex { |frm| frm.path.index re } @frames[logframe + 1 .. -1] end |