Class: Logue::Stack

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#framesObject (readonly)

Returns the value of attribute frames.



8
9
10
# File 'lib/logue/stack.rb', line 8

def frames
  @frames
end

Instance Method Details

#filteredObject



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