Which classes are installed on my system?

Hello everyone,

Even though these seem extremely silly and simple questions, I haven't
yet seen this information in the FAQ or on the Web. I must be looking
in the wrong places.

For general information I have looked at
Http://dev.rubycentral.com/book/builtins.html however, my question is
about my specific system.

How do I see the list of all the classes or methods installed on my
specific system?

Can I determine proper usage of a specific method installed on my
system using a man page or something similar?

Thank you,

Todd

Hello everyone,

Even though these seem extremely silly and simple questions, I haven't
yet seen this information in the FAQ or on the Web. I must be looking
in the wrong places.

For general information I have looked at
Http://dev.rubycentral.com/book/builtins.html however, my question is
about my specific system.

How do I see the list of all the classes or methods installed on my
specific system?

If you have ri installed, run `ri -c` to get a list of known classes. If the ri database was made properly, It will list allt eh classes installed with Ruby.

Can I determine proper usage of a specific method installed on my
system using a man page or something similar?

`ri SomeObject#some_method` or `ri SomeObject::some_method`.

If you don't have ri installed (it comes standard with recent versions of Ruby) check out the stdlib docs at RDoc Documentation

HTH,
Mark

···

On Jun 18, 2004, at 1:58 AM, Todd Gardner wrote:

For a list of classes, just try the following code snippet:

ObjectSpace.each_object(Class) do |c|
    puts c
end

If you want more detail on a given class, you can use 'ri', as Mark
recommended, or just try 'Klassname.instance_methods'.

Lennon

This will give a list of loaded classes. Complex, for instance will not be visible until you 'require "complex"' (or "mathn", etc).

cheers,
Mark

···

On Jun 18, 2004, at 11:14 AM, Lennon Day-Reynolds wrote:

For a list of classes, just try the following code snippet:

ObjectSpace.each_object(Class) do |c|
    puts c
end

Mark Hubbart wrote:

For a list of classes, just try the following code snippet:

ObjectSpace.each_object(Class) do |c|
    puts c
end

This will give a list of loaded classes. Complex, for instance will not be visible until you 'require "complex"' (or "mathn", etc).

cheers,
Mark

So much is true, however if you 'require "whatever"' and "whatever" is unknown to ri - perhap noone ever bother do write any documentation [1] - then 'ri -c' won't tell you about that I guess.

On second thought Todd's question isn't *that* easy to answer I think.

Happy rubying

Stephan

[1] Of course, noone would ever even think of not documenting h(is|er)
     software...

···

On Jun 18, 2004, at 11:14 AM, Lennon Day-Reynolds wrote:

Stephan Kämper wrote:

Mark Hubbart wrote:

For a list of classes, just try the following code snippet:

ObjectSpace.each_object(Class) do |c|
    puts c
end

This will give a list of loaded classes. Complex, for instance will not be visible until you 'require "complex"' (or "mathn", etc).

On second thought Todd's question isn't *that* easy to answer I think.

The attached gives a better idea when you run it on windows. Be careful with it. It comes with no warranties. The fact that it requires almost every library on your system make cause serious problems depending on the libraries you have installed. It worked for me.

Shouldn't be that hard to get the script to work on linux.

list-classes.rb (1.63 KB)

···

On Jun 18, 2004, at 11:14 AM, Lennon Day-Reynolds wrote:

--
John