El Martes 31 Marzo 2009, Sean O'Halpin escribi=F3:
> On Mon, Mar 30, 2009 at 10:32 PM, I=F1aki Baz Castillo <ibc / aliax.net> wr=
ote:
> > Hi, first of all I'm sorry since I already did this question some time
> > ago (but I ca't find it now).
> >
> > Basically I want the following:
> >
> > ---------------
> > module MyModule
> >
> >  class MyClass
> >    def show_log
> >      puts "I'm here: ###### FIXME ######"
> >    end
> >  end
> >
> > end
> >
> >
> > my_class =3D MyModule::MyClass.new
> > my_class.show_log
> > =3D> I'm here: MyModule::MyClass#show_log
> > ---------------
> >
> > When I did this question I remember that it was not possible with Ruby
> > 1.8 but it was feasible in Ruby 1.9.
> >
> > Could you please show me how to get it?
> > Thanks a lot.
>
> Hi,
>
> The following works in both 1.8.6 and 1.9.1 (calling_method is by
> Robert Klemme - see ruby-talk 205150 & 205950).
>
> module Kernel
>   private
>   def calling_method(level =3D 1)
>     caller[level] =3D~ /`([^']*)'/ and $1
>   end
>
>   def this_method
>     calling_method
>   end
> end
>
> module MyModule
>   class MyClass
>     def show_log
>       puts "#{self.class}.#{this_method}"
>     end
>   end
> end
>
> MyModule::MyClass.new.show_log # =3D> MyModule::MyClass.show_log


=46antastic! Thanks a lot.

=2D-=20
I=F1aki Baz Castillo <ibc / aliax.net>