Probably not the best solution, but you could load the code into an
instance of a class. For example, in a file ‘test.rb’:
puts “this is my method”
Then in your main file (this is in irb, so you’ll need to remove some
x = ExternalCode.new
this is my method
On Dec 23, 2007 3:21 PM, Daniel Brumbaugh K.
[email protected] wrote:
Basically, I was wondering if it is possible in Ruby to eval a file
without loading the whole thing in memory. I’m trying to avoid
eval(File.new(location).read), but at the same time, I don’t want the
file to contain a named method that could conflict with other named
-Daniel Brumbaugh K.
Ruby in Practice
My free Ruby e-book