Skip to content

Instantly share code, notes, and snippets.

@aviflombaum
Created May 9, 2013 18:43
Show Gist options
  • Select an option

  • Save aviflombaum/5549578 to your computer and use it in GitHub Desktop.

Select an option

Save aviflombaum/5549578 to your computer and use it in GitHub Desktop.
module Kernel
def caller_method_name
parse_caller(caller(2).first).last
end
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = Regexp.last_match[1]
line = Regexp.last_match[2].to_i
method = Regexp.last_match[3]
[file, line, method]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment