Posted to the ruby-talk list by Ara T Howard ============================================ most of my standalone production code looks like this % cat foo module Foo class Main ... end end Foo::Main.run(ARGV, ENV) if __FILE__ == $0 that way foo runs as a script. however the code can be re-used in this way too % cat bar require 'foo' module Bar class Main < Foo::Main argv << '--foo-option=42' env['foo_env'] = 42 super(argv, env) end end Bar::Main.run(ARGV, ENV) if __FILE__ == $0 or in this way: foo = Foo::Main.new '--key=val --k2-v2' etc. basically i re-use top-level code as libs sometimes and then it's important that two bits of code aren't fighting over ARGV/ENV.