Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2014 16:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?


Build a bot that triggers searches on and returns the results in a specific format.


  • The bot should respond to ComThetrainline.find(from, to, departure_at).
  • Assume that the parameters from and to will be EXACTLY what you need.
  • departure_at will be a Ruby DateTime object.


find() should return an array. Each element of the array should be an option for a trip. E.g. If you search for London to Paris, and they give you 10 "segments" leaving each hour on the hour, the array size should be 10. Each "segment" should be in this format and should include all data:

# Segment
      :departure_station => "Ashchurch For Tewkesbury",
           :departure_at => #<DateTime: 2014-04-26T06:09:00+00:00 ((2456774j,22140s,0n),+0s,2299161j)>,
        :arrival_station => "Ash",
             :arrival_at => #<DateTime: 2014-04-26T09:37:00+00:00 ((2456774j,34620s,0n),+0s,2299161j)>,
       :service_agencies => ["thetrainline"],
    :duration_in_minutes => 208,
            :changeovers => 2,
               :products => ["train"],
                  :fares => ["See below"],
# Fare
                       :name => "Advance Single",
             :price_in_cents => 1939,
                   :currency => "GBP",
              :comfort_class => 1,


  • We use Ruby 2.0.0-p353, but if you just use 2.0, I think it will be fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment