title: Truncate string when it is too long
body: <p>I have two strings:</p>
  
  <pre><code>short_string = "hello world"
  long_string = "this is a very long long long .... string" # suppose more than 10000 chars
  </code></pre>
  
  <p>I want to change the default behavior of <code>print</code> to:</p>
  
  <pre><code>puts short_string
  # =&gt; "hello world"
  puts long_string
  # =&gt; "this is a very long long....."
  </code></pre>
  
  <p>The <code>long_string</code> is only partially printed. I tried to change <code>String#to_s</code>, but it didn't work. Does anyone know how to do it like this?</p>
  
  <p><strong>updated</strong></p>
  
  <p>Actually i wanna it works smoothly, that means the following cases also work fine:</p>
  
  <pre><code>&gt; puts very_long_str
  &gt; puts [very_long_str]
  &gt; puts {:a =&gt; very_long_str}
  </code></pre>
  
  <p>So i think the behavior belongs to String.</p>
  
  <p>Thanks all anyway.</p>