From: dblack@... Date: 2006-04-11T11:47:09+09:00 Subject: Re: Identfying classes in a file dynamically 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. David -- David A. Black (dblack@wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" coming in PDF April 15, and in paper May 5! http://www.manning.com/black