I would like to do something like this from a Ruby script, within a loop:
- Write a file a.rb (which changes each iteration)
- execute system(ruby 'a.rb')
- a.rb writes a string with results to a file 'results'
- a.rb finishes and Ruby returns 'true' (assuming no errors)
- the calling script reads the file 'results' and takes action.
I expect there are many better ways of doing this. For example, instead of step #2-#5 could I simply load 'a.rb' (within the loop) and invoke one one of its methods? Is there a better way by using eval() or something else? (Gaining an understanding of metaprogramming is on my Ruby to-do list.)