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

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-forum.com/.

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/quiz38.html

See Florian Gross's solution, for example.

James Edward Gray II

···

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.