I have been working on a couple of Ruby wrappers for some fortran
programs. They are running a bit long (300+ lines), however Ruby has
been excellent in handling them.
My concerns are they are a bit too long to join together in one program,
but they will often run together. I want the second script to be run
independently, but if the first one is run, I want the second to be
called from within the first.
Is the best way to accomplish this to write a line in the first script: /usr/local/bin/secondscript.rb
This doesn’t seem to be the Ruby way since it relies on the shell, plus
I would like to send some global variables across if continued from the
first script.
It works like require, but will always evaluate the file, instead of
doing so conditionally.
···
On Monday 08 December 2003 10:32 am, Qubert wrote:
I have been working on a couple of Ruby wrappers for some fortran
programs. They are running a bit long (300+ lines), however Ruby has
been excellent in handling them.
My concerns are they are a bit too long to join together in one
program, but they will often run together. I want the second script
to be run independently, but if the first one is run, I want the
second to be called from within the first.
Is the best way to accomplish this to write a line in the first
script: /usr/local/bin/secondscript.rb
This doesn’t seem to be the Ruby way since it relies on the shell,
plus I would like to send some global variables across if continued
from the first script.
Is the best way to accomplish this to write a line in the first script: /usr/local/bin/secondscript.rb
This doesn’t seem to be the Ruby way since it relies on the shell, plus
I would like to send some global variables across if continued from the
first script.
I’ll wrap up the main functions in a method.
then adding something like this
script 1
if FILE=$0
function_one()
load ‘script2’
function_two()
end
I’ll wrap up the main functions in a method.
then adding something like this
script 1
if FILE=$0
function_one()
load ‘script2’
function_two()
end
#script 2
if FILE=$0
function_two()
end
and so on… maybe someone has a better way
File 1
class A
def x; end
def y; end
def z; end
def A.run(args); end
end
if FILE == $0
A.run(ARGV)
end
File 2
require ‘File 1’
class B
def x; end
def y; end
def z; end
def B.run(args); end
end
if FILE == $0
B.run(ARGV)
end
Although my simple scripts generally begin life as a bunch of top-level
methods and so on, they usually evolve to an “application” class. It’s
just easier to arrange things that way I find.