From ruby-talk Mon Feb 02 07:42:08 2004 From: Emmanuel Touzery Date: Mon, 02 Feb 2004 07:42:08 +0000 To: ruby-talk Subject: Re: Method Reflection Message-Id: <401DFFE2.9060002 () wanadoo ! fr> X-MARC-Message: https://marc.info/?l=ruby-talk&m=107570778422735 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