$0
is the variable for the top level Ruby program, but is there one for the current method?
Even better than my first answer you can use __method__:
class Foo
def test_method
__method__
end
end
This returns a symbol – for example, :test_method
. To return the method name as a string, call __method__.to_s
instead.
Note: This requires Ruby 1.8.7.