[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: Method Reflection
From: Emmanuel Touzery <emmanuel.touzery () wanadoo ! fr>
Date: 2004-02-02 7:42:08
Message-ID: 401DFFE2.9060002 () wanadoo ! fr
[Download RAW message or body]
Benedikt Huber wrote:
>I'm quite new to ruby and was amazed by the powerful reflection
>mechanism, so tried to use the tracing function to analyse the object
>space of our project.
>
>It was amazingly easy to dump module,class and method definitions to xml
>as they occured, but i was not able to retrieve any information about
>the formal method parameters (correct term?), neither the number nor the
>name.
>
>
http://www.rubycentral.com/book/ref_c_method.html
arity gives the number of parameters (check the special cases in the doc
with method with variable number of parameters -with optional parameters-).
irb(main):001:0> a = String.new
=> ""
irb(main):002:0> a.method('split').arity
=> -1
irb(main):004:0> a.method('insert').arity
=> 2
i'm afraid you can't get the name of the parameters at runtime (this is
a job for rdoc).
>I wasn't able to retrieve information on instance variables as
>well. Is it possible ?
Apparently there is a instance_variables method.
emmanuel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic