From: Joel VanderWerf Date: 2006-04-11T12:17:05+09:00 Subject: Re: Identfying classes in a file dynamically dblack@wobblini.net wrote: > Hi -- > > On Tue, 11 Apr 2006, Joel VanderWerf wrote: > >> dblack@wobblini.net wrote: >> ... >>> Also I think that if the read-in file uses the ::Const construct, >>> those classes won't get counted. >> >> You mean like this: >> >> $ cat t.rb >> class ::Foo >> end >> $ ruby -e 'load "t.rb"; p Foo' >> Foo >> $ ruby -e 'load "t.rb"; ObjectSpace.each_object(Class) {|c| p c if >> c.name == "Foo"}' >> Foo >> >> So it doesn't look like that works, unless I'm misunderstanding... > > Yes, that's what I meant; if you have ::Foo in your file, then you > won't get a Foo class in the module you wrap in, so you won't get the > right count of modules in the file. Oh, I see--I thought you meant it was a workaround, but it's actually a limitation of the module wrapping trick. Good point. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407