[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how can I dynamically get the source of an object's method?

David Lowenfels

11/15/2006 8:37:00 AM

Hello:

I've been wondering if it's possible to get an object to print out the
source code of a method into a string.

It seems like it _should_ be possible, but it's kind of a wacky idea. I
haven't seen it mentioned anywhere.

Thanks in advance,
David

--
Posted via http://www.ruby-....

1 Answer

James Gray

11/15/2006 2:33:00 PM

0

On Nov 15, 2006, at 2:37 AM, David Lowenfels wrote:

> I've been wondering if it's possible to get an object to print out the
> source code of a method into a string.

This isn't easy in the general sense with Ruby, because you can use
code to write, or even change, code.

However, some of the tricks for the SerializableProc Ruby Quiz might
give you ideas:

http://www.rubyquiz.com/q...

See Florian Gross's solution, for example.

James Edward Gray II