From: Dave Burt Date: 2006-05-18T00:37:09+09:00 Subject: Re: Method name Mark Volkmann wrote: > On 5/17/06, Michael wrote: >> Hi, >> >> I'm looking around, but I didn't find a replacement for c++ >> __PRETTY_FUNCTION__ or __FUNC__ macro. >> >> How can I find out a method's name at runtime? > > I assume you mean the name of the current method. Here's one way. > > name = caller(0).first.split.last > > This gives it to you with single quotes around it which you may want > to strip off. Does this work? def __FUNCTION__ caller(1).first[/ `(.*)'\Z/, 1] end Cheers, Dave