dbrady_trainline
Build a bot that triggers searches on http://thetrainline.com and returns the results in a specific format.
Input
- The bot should respond to
ComThetrainline.find(from, to, departure_at)
. - Assume that the parameters
from
andto
will be EXACTLY what you need. departure_at
will be a Ruby DateTime object.
Output
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,
},
Misc
- We use Ruby 2.0.0-p353, but if you just use 2.0, I think it will be fine.