Look at Facets: facets/ruby.rb. There is 1.8 implementation of #__method__.
# Retreive the current running method name.
···
On Apr 6, 9:25 am, Iñaki Baz Castillo <i...@aliax.net> 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.
#
# 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
On Apr 6, 9:25 am, Iñaki Baz Castillo <i...@aliax.net> 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