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.
8dddac306e16a7ef8146372c2271c4c6?d=identicon&s=25 amrangaye (Guest)
on 2005-12-25 16: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.
9dfe8c734b0f9b37a4e218425c0a2138?d=identicon&s=25 Gene Tani (Guest)
on 2005-12-25 18: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.
9706ce6b47a9af06e1f37b7584fb3fab?d=identicon&s=25 Ilias Lazaridis (Guest)
on 2005-12-26 05: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.