Module: Sqrbl::CallStack

Defined in:
lib/sqrbl/call_stack.rb

Overview

A small set of tools for working with the call stack.

Class Method Summary collapse

Class Method Details

.caller_file(caller_item) ⇒ Object

For a given entry in the call stack, get the file



12
13
14
# File 'lib/sqrbl/call_stack.rb', line 12

def caller_file(caller_item)
  caller_item.split(':')[0]
end

.caller_line(caller_item) ⇒ Object

For a given entry in the call stack, get the line number



17
18
19
# File 'lib/sqrbl/call_stack.rb', line 17

def caller_line(caller_item)
  caller_item.split(':')[1]
end

.first_non_sqrbl_caller(call_stack = caller) ⇒ Object

Find the first item on the call stack that isn’t in the Sqrbl library path



7
8
9
# File 'lib/sqrbl/call_stack.rb', line 7

def first_non_sqrbl_caller(call_stack = caller)
  call_stack.detect { |call| ! call.include?(Sqrbl::LIBPATH) }
end