title: finding nearest record by time in ruby
body: <p>The following code works but doesn't seem very ruby-like so I am looking for a better way to achieve the same.</p>
  
  <pre><code>#Grab the events from the page 
    events = page.events.sort_by{|e| e.start_time}
  
    upcoming = []
    past = []
  
    events.each do |e|
      if e.start_time &gt;= Time.now
        upcoming.push(e)
      end
      if e.start_time &lt; Time.now
        past.push(e)
      end
    end
  
   # show the most nearest event (current events if exist)
   event_to_show = (upcoming.count &lt; 0) ? upcoming.first : past.last
  </code></pre>