title: How can I join these time-tables together using Ruby?
body: <p>My final result should be like this:</p>
  
  <pre><code>[
    { name: 01, start_date: '2014-04-24 22:03:00', start_location: 'A', end_date: '2014-04-24 22:10:00', end_location: 'BC' },
    { name: 06, start_date: '2014-04-24 22:15:00', start_location: 'BC', end_date: '2014-04-24 22:20:00', end_location: 'RI' },
    { name: 05, start_date: '2014-04-24 22:20:00', start_location: 'RI', end_date: '2014-04-24 23:10:00', end_location: 'XX' },
    { name: 03, start_date: '2014-04-24 23:15:00', start_location: 'XX', end_date: '2014-04-24 00:10:00', end_location: 'E' }
  ]
  </code></pre>
  
  <p>This is my code so far, BUT it's not working unfortunately:</p>
  
  <pre><code>arr =   [
    { name: 01, start_date: '2014-04-24 22:03:00', start_location: 'A', end_date: '2014-04-24 22:10:00', end_location: 'BC' },
    { name: 05, start_date: '2014-04-24 22:20:00', start_location: 'RI', end_date: '2014-04-24 23:10:00', end_location: 'XX' },
    { name: 01, start_date: '2014-04-24 17:10:00', start_location: 'X', end_date: '2014-04-24 20:10:00', end_location: 'B' },
    { name: 01, start_date: '2014-04-24 17:10:00', start_location: 'Z', end_date: '2014-04-24 20:10:00', end_location: 'B' },
    { name: 06, start_date: '2014-04-24 22:15:00', start_location: 'BC', end_date: '2014-04-24 22:20:00', end_location: 'RI' },
    { name: 03, start_date: '2014-04-24 23:15:00', start_location: 'XX', end_date: '2014-04-24 00:10:00', end_location: 'E' }
  ]
  new_array = []
  
  # i = 0
  # while i &lt;= 5 do
  #   if arr[i][:end_location] == arr[i+1][:start_location] &amp;&amp; arr[i][:start_date] &lt;= arr[i+1][:start_date]
  #     new_array &lt;&lt; arr[i]
  #   end
  #   i = i + 1
  #   puts new_array
  # end
  </code></pre>
  
  <p>It'd be nice to get some insights how to solve this problem!</p>