Forum: Ruby Method introspection question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
amrangaye (Guest)
on 2005-12-25 17:14
(Received via mailing list)
Hello

Is there anyway to get back the definition of a method within a running
program [or irb session]?

For example, if I declare a method:

def hello
 puts "Hello"
end


is there anything like hello.source to get back hello's code?

Thanks.
Gene T. (Guest)
on 2005-12-25 19:34
(Received via mailing list)
amrangaye wrote:
>
>
> is there anything like hello.source to get back hello's code?
>
> Thanks

look at ParseTree or Scrit_lines__,
http://blog.zenspider.com/archives/parsetree/index.html
http://redhanded.hobix.com/inspect/whoaScript_lines__.html.
Ilias L. (Guest)
on 2005-12-26 06:23
(Received via mailing list)
amrangaye wrote:
>
>
> is there anything like hello.source to get back hello's code?

http://lazaridis.com/case/lang/ruby/base.html#sayY...

If you implement an solution, please contact me via private email, thus
I can update the document.

This way evaluators (or users) can immediately detect (and use) the
functionality.

> Thanks.

..
This topic is locked and can not be replied to.