title: Ruby: Round number down to nearest number based on arbitrary list of numbers
body: <p>Say I have an array of integers:</p>
  
  <pre><code>arr = [0,5,7,8,11,16]
  </code></pre>
  
  <p>and I have another integer:</p>
  
  <pre><code>n = 6
  </code></pre>
  
  <p>I need a function that rounds down to the nearest number from the array:</p>
  
  <pre><code>foo(n) #=&gt; 5
  </code></pre>
  
  <p>As you can see, the numbers do not have a fixed pattern. What's an elegant way to do this?</p>
  
  <p>Thanks</p>