Skip to content

Instantly share code, notes, and snippets.

@roryokane
Created June 18, 2012 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roryokane/2949232 to your computer and use it in GitHub Desktop.
Save roryokane/2949232 to your computer and use it in GitHub Desktop.
`self.inspect == 'main'` is no substitute for `__FILE__ == $0`
require './main-tester'
puts "done in caller"
if self.inspect == 'main'
puts "I'm main"
else
puts "I'm a library"
end
$ ruby main-tester.rb
I'm main
$ ruby main-tester-caller.rb
I'm main
done in caller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment