From: Trans Date: 2008-04-07T01:16:47+09:00 Subject: Re: Is posible to get the Module(s), Class and Method names in which we are? On Apr 6, 9:25 am, Iñaki Baz Castillo wrote: > El Domingo, 6 de Abril de 2008, Tim Hunter escribió: > > > Iñaki Baz Castillo wrote: > > > The only I miss if the method name, is ti possible? > > > In 1.9 there is Method#name, but in 1.8.6 I think your best bet is to > > parse the output from Kernel#caller. > > Thanks, I'll try it. Look at Facets: facets/ruby.rb. There is 1.8 implementation of #__method__. # Retreive the current running method name. # # def tester; __method__; end # tester #=> :tester # # Technically __callee__ should provided alias names, # where __method__ should not. But we'll have to # leave that distinction to Ruby 1.9+. def __method__ /\`([^\']+)\'/.match(caller(1).first)[1].to_sym end T.