अब Google Groups, यूज़नेट फ़ोरम में नई पोस्ट करने या उसकी सदस्यता लेने की सुविधा नहीं देता है. हालांकि, यूज़नेट फ़ोरम में मौजूद पुराना कॉन्टेंट देखा जा सकता है.

Does ruby have a similar functions to the Python dir and help functions?

69 बार देखा गया
नहीं पढ़े गए पहले मैसेज पर जाएं

py

नहीं पढ़ी गई,
23 मार्च 2007, 9:47:58 am23/3/07
ईमेल पाने वाला
In python during runtime, or in the python shell you can type:

dir()

or

dir(<some_object>)

and get a list of variables, methods etc that exist for that object.

Also there is help(<some_object>), or help(<some_object.aMethod>).

does ruby have similar functions. I know that you can use ri....but
is there a function to call while in the ruby shell?

thanks

Austin Ziegler

नहीं पढ़ी गई,
23 मार्च 2007, 9:54:00 am23/3/07
ईमेल पाने वाला
Ruby can tell you the methods: obj.methods (there's also
#public_methods, #instance_methods, #private_methods, etc.). Ruby can
tell you the instance variables (#instance_variables).

Ruby can't tell you the documentation; there's no docstring like there
is in Python. There are some enhancements to irb available that give
an ri command from within irb.

-austin
--
Austin Ziegler * halos...@gmail.com * http://www.halostatue.ca/
* aus...@halostatue.ca * http://www.halostatue.ca/feed/
* aus...@zieglers.ca

Jeremy McAnally

नहीं पढ़ी गई,
23 मार्च 2007, 10:26:11 am23/3/07
ईमेल पाने वाला
def dir(object)
object.methods.sort
end

That should give you the same effect; as for the help method, ri is
your only option AFAIK.

--Jeremy


--
http://www.jeremymcanally.com/

My free Ruby e-book:
http://www.humblelittlerubybook.com/book/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/

Olivier Renaud

नहीं पढ़ी गई,
23 मार्च 2007, 12:40:33 pm23/3/07
ईमेल पाने वाला
Le vendredi 23 mars 2007 14:54, Austin Ziegler a écrit :
> Ruby can tell you the methods: obj.methods (there's also
> #public_methods, #instance_methods, #private_methods, etc.). Ruby can
> tell you the instance variables (#instance_variables).
>
> Ruby can't tell you the documentation; there's no docstring like there
> is in Python. There are some enhancements to irb available that give
> an ri command from within irb.
>
> -austin

Actually, irb can give you documentation. For example :

irb(main):001:0> help Array

It works like ri.

--
Olivier Renaud

Jonas Pfenniger

नहीं पढ़ी गई,
23 मार्च 2007, 12:52:05 pm23/3/07
ईमेल पाने वाला
There is also the IHelp project : http://fhtr.org/projects/ihelp/

--
Cheers,
zimbatm

Daniel DeLorme

नहीं पढ़ी गई,
24 मार्च 2007, 4:54:24 am24/3/07
ईमेल पाने वाला
Austin Ziegler wrote:
> Ruby can tell you the methods: obj.methods (there's also
> #public_methods, #instance_methods, #private_methods, etc.). Ruby can
> tell you the instance variables (#instance_variables).

you can also use local_variables to get a list of... local variables!

Daniel


0 नया मैसेज