topic says it all
for example irb knows many classes like Dir, File, Process, Thread ..
can I somehow list them, maybe the are kept in some array ..
if it's possible, can additional classes provided through
require "foo"
be listet too?
Wayne Vucenic
No Bugs Software
Ruby and C++ Agile Contract Programming in Silicon Valley
···
On 11/30/05, Daniel Schüle <uval@rz.uni-karlsruhe.de> wrote:
Hello,
topic says it all
for example irb knows many classes like Dir, File, Process, Thread ..
can I somehow list them, maybe the are kept in some array ..
if it's possible, can additional classes provided through
require "foo"
be listet too?
topic says it all
for example irb knows many classes like Dir, File, Process, Thread ..
can I somehow list them, maybe the are kept in some array ..
if it's possible, can additional classes provided through
require "foo"
be listet too?
A slightly more hackish solution I think that might also work with autoloads (way too early in the morning to go and code it), is to use #constants, eval those, select the ones that are classes, recurse, rinse, repeat. Mind you, this is potentially a much worse resource hog than the ObjectSpace approach.
Not sure exactly which list of "classes available" you want, but if you wanted to know all the classes available to the interpreter to load, then you could conceivably iterate the directories in $:, the load path, and look at all .rb files in them and their subdirectories and parse them for the classes that they define.
Bob
···
On Nov 30, 2005, at 2:52 PM, Daniel Schüle wrote:
Hello,
topic says it all
for example irb knows many classes like Dir, File, Process, Thread ..
can I somehow list them, maybe the are kept in some array ..
if it's possible, can additional classes provided through
require "foo"
be listet too?
Note, that all approaches using ObjectSpace list only classes known to the
interpreter at this moment. There might be more classes whose files
haven't been required / loaded yet. You won't see them. Also, additional
classes may be generated dynamically.
Note, that all approaches using ObjectSpace list only classes known to the
interpreter at this moment. There might be more classes whose files
haven't been required / loaded yet. You won't see them. Also, additional
classes may be generated dynamically.
Kind regards
robert
right, and immediate values are kind of important:Fixnum, Symbol,
TrueClass, FalseClass, NilClass ;-p}