title: Checking if a Ruby program was executed or imported via require
body: <p>How do you check if a Ruby file was imported via "require" or "load" and not simply executed from the command line?</p>
  
  <p>For example:</p>
  
  <p>Contents of foo.rb:</p>
  
  <pre><code>puts "Hello"
  </code></pre>
  
  <p>Contents of bar.rb</p>
  
  <pre><code>require 'foo'
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>$ ./foo.rb
  Hello
  $ ./bar.rb
  Hello
  </code></pre>
  
  <p>Basically, I'd like calling bar.rb to not execute the puts call.</p>