Skip to content

Instantly share code, notes, and snippets.

@jamiecobbett
Created December 1, 2009 19:45
Show Gist options
  • Save jamiecobbett/246574 to your computer and use it in GitHub Desktop.
Save jamiecobbett/246574 to your computer and use it in GitHub Desktop.
Ruby - is the file being run directly
# http://stackoverflow.com/questions/582686/should-i-define-a-main-method-in-my-ruby-scripts/582694#582694
# Detect if the file is being run directly.
#if __FILE__ == $PROGRAM_NAME
if __FILE__ == $0
x = SweetClass.new(ARGV)
x.run # or go, or whatever
end
@zapp42
Copy link

zapp42 commented Dec 17, 2013

Thanks for sharing. Exactly what I was looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment