From: Brian Candler Date: 2011-10-12T05:49:54+09:00 Subject: Re: A .rb file without module, loading it inside a new module at runtime. Marc Heiler wrote in post #1026065: > Can I load the whole thing into a module at runtime? Yes, but it's not especially pretty: eval "module NewModule\n" + File.read("foobar.rb") + "\nend" or: module NewModule; end NewModule.class_eval File.read("foobar.rb") Note that modules don't actually have to have (constant) names: mm = Module.new mm.class_eval File.read("foobar.rb") But if you do want to create a constant with a dynamic name, there's const_set. -- Posted via http://www.ruby-forum.com/.