Created
December 1, 2009 19:45
-
-
Save jamiecobbett/246574 to your computer and use it in GitHub Desktop.
Ruby - is the file being run directly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing. Exactly what I was looking for.