title: Ruby: Split a string into substring of maximum 40 characters
body: <p>I have some strings with a sentence and i need to subdivise it into a substring of maximum 40 characters.
  But i don't want to split the sentence in the middle of a word. </p>
  
  <p>I tried with .gsub function but it's return 40 characters maximum and avoid to cut the string in the middle of a word. But it's return only the first occurence.</p>
  
  <pre><code>sentence[0..40].gsub(/\s\w+$/,'')
  </code></pre>
  
  <p>I tried with split but i can select only the fist 40 characters and split in the middle of a word...</p>
  
  <pre><code>sentence.split(...){40}
  </code></pre>
  
  <p>My string is <code>"Sure, we will show ourselves only when we know the east door has been opened."</code>.
  The string output i want is </p>
  
  <pre><code> ["Sure, we will show ourselves only when we","know the east door has
   been opened."]
  </code></pre>
  
  <p>Do you have a solution ? Thanks </p>