title: Placing a box around centered text in Ruby
body: <p>This is a super basic ruby question. Just learning ruby and I'm trying to build out a box where it finds the longest word in the string and makes the box that width with spaces on either side and then centers all the other text i've passed in.</p>
  
  <p>so far i have this;</p>
  
  <pre><code>def box(str)
  arr = str.split
  wordlength = arr.max_by(&amp;:length).length 
  width = wordlength + 4
  
  width.times{print "*"}
  puts "\n"
  arr.each {|i| puts "* #{i} *" }
  width.times{print "*"}
  end
  </code></pre>
  
  <p>but the above prints out:</p>
  
  <pre><code>***********
  * texting *
  * stuff *
  * test *
  * text *
  ***********
  </code></pre>
  
  <p>i'd like it to print something like the below</p>
  
  <pre><code>***********
  * texting *
  *  stuff  *
  *  test   *
  *  text   *
  ***********
  </code></pre>
  
  <p>thanks</p>