There is no such function in MRI. But there are several alternatives.
If you use Rubinius, you can do this instead of parsing caller :
Rubinius::VM.backtrace(1, false).first.name
You can also use the gem to analyze the caller result for you. It should work for any Ruby> 1.9.
The answer to this SO question describes how you can do a simple analysis yourself.
And finally, it seems that work is ongoing to get such a feature in Ruby 2.0, although the corresponding ticket has not been updated for some time.
source share