From: gabriele renzi Date: 2004-07-27T22:06:50+09:00 Subject: Re: code introspection il Mon, 26 Jul 2004 23:56:40 +0900, Daniel Cremer ha scritto:: >> If you don't know class names beforehand, you can work with an anonymous >> module as wrapper like this: >> >> mod = Module.new >> mod.class_eval( File.read( "foo.rb" ) ) >> new_classes = mod.constants.inject([]) {|ar,c| cl=mod.const_get(c); ar << >> cl if Class === cl; ar} >> p new_classes >> include mod >> p Foo >> >> (...) > >ahh... it looks like creating an anonymous module is the piece that is >really missing for me at the moment... >thanks for the ideas, I'm not sure how far I'll have to carry this so >they're all appreciated > well, than take a look at the simple load: load(filename, wrap=false) => true ----------------------------------------------------------------------- Loads and executes the Ruby program in the file _filename_. If the filename does not resolve to an absolute path, the file is searched for in the library directories listed in +$:+. If the optional _wrap_ parameter is +true+, the loaded script will be executed under an anonymous module, protecting the calling program's global namespace. In no circumstance will any local variables in the loaded file be propagated to the loading environment.