title: What is wrong with this Ruby CASE statement?
body: <p>I have the following ruby function, and when I call it `deg_to_dir 270' the case statement never matches, when it should return W.  I have been pulling my hair out and short of converting the entire thing to IF statements I don't have a next step.</p>
  
  <pre><code>def deg_to_dir deg
    # used logic from http://www.csgnetwork.com/degrees2direct.html
    d = deg.to_f
    dir = "#{d}°"
    case d
      when d &gt;=  0    &amp;&amp; d &lt;=  11.25,
           d &gt; 348.75 &amp;&amp; d &lt;= 360
        dir = "N"
      when d &gt;  11.25 &amp;&amp; d &lt;=  33.75
        dir = "NNE"
      when d &gt;  33.75 &amp;&amp; d &lt;=  56.25
        dir = "NE"
  
      when d &gt;  56.25 &amp;&amp; d &lt;=  78.75
        dir = "ENE"
      when d &gt;  78.75 &amp;&amp; d &lt;= 101.25
        dir = "E"
      when d &gt; 101.25 &amp;&amp; d &lt;= 123.75
        dir = "ESE"
  
      when d &gt; 123.75 &amp;&amp; d &lt;= 146.25
        dir = "SE"
      when d &gt; 146.25 &amp;&amp; d &lt;= 168.75
        dir = "SSE"
      when d &gt; 168.75 &amp;&amp; d &lt;= 191.25
        dir = "S"
      when d &gt; 191.25 &amp;&amp; d &lt;= 213.75
        dir = "SSW"
      when d &gt; 213.75 &amp;&amp; d &lt;= 236.25
        dir = "SW"
  
      when d &gt; 236.25 &amp;&amp; d &lt;= 258.75
        dir = "WSW"
      when d &gt; 258.75 &amp;&amp; d &lt;= 281.25
        dir = "W"
      when d &gt; 281.25 &amp;&amp; d &lt;= 303.75
        dir = "WNW"
      when d &gt; 303.75 &amp;&amp; d &lt;= 326.25
        dir = "NW"
      when d &gt; 326.25 &amp;&amp; d &lt;= 348.75
        dir = "NNW"
    end
    dir
  end
  </code></pre>