[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Method introspection question

amrangaye

12/25/2005 10:04:00 AM

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.

2 Answers

Gene Tani

12/25/2005 5:31:00 PM

0


amrangaye wrote:
> 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

look at ParseTree or Scrit_lines__,
http://blog.zenspider.com/archives/parsetree/...
http://redhanded.hobix.com/inspect/whoaScript_li....

Ilias Lazaridis

12/26/2005 4:20:00 AM

0

amrangaye wrote:
> 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?

http://laz.../case/lang/ruby/base.html#sayYou...

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.

.

--
http://laz...