From: Gavin Sinclair Date: 2003-12-09T09:08:45+09:00 Subject: Re: Joining scripts? [gabriele renzi ha scritto:] > 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. Gavin