Class: SamtrafikenAPI::Resrobot
- Defined in:
- lib/samtrafiken_api/resrobot.rb
Overview
Samtrafiken ResRobot API.
Documentation: http://www.trafiklab.se/api/resrobot-sok-resa
Instance Attribute Summary
Attributes inherited from APIBase
Class Method Summary collapse
-
.uris ⇒ Object
debug_output $stdout.
Instance Method Summary collapse
-
#find_location(query) ⇒ Hash
Endpoint: FindLocation.
-
#producer_list ⇒ Hash
Endpoint: ProducerList.
-
#search(query) ⇒ Hash
Endpoint: Search.
-
#set_mode(mode) ⇒ Object
Set the API mode to use either real time or time table data.
-
#stations_in_zone(query) ⇒ Hash
Endpoint: StationsInZone.
-
#time_table_period ⇒ Hash
Endpoint: TimeTablePeriod.
-
#transport_mode_list ⇒ Hash
Endpoint: TransportModeList.
Methods inherited from APIBase
Constructor Details
This class inherits a constructor from SamtrafikenAPI::APIBase
Class Method Details
.uris ⇒ Object
debug_output $stdout
19 20 21 22 23 24 |
# File 'lib/samtrafiken_api/resrobot.rb', line 19 def self.uris { timetable: 'https://api.trafiklab.se/samtrafiken/resrobot', realtime: 'https://api.trafiklab.se/samtrafiken/resrobotsuper' } end |
Instance Method Details
#find_location(query) ⇒ Hash
Endpoint: FindLocation
Documentation: http://www.trafiklab.se/api/resrobot/findlocation
97 98 99 100 |
# File 'lib/samtrafiken_api/resrobot.rb', line 97 def find_location query @response = self.class.get('/FindLocation.json', :query => query) return read_response @response end |
#producer_list ⇒ Hash
Endpoint: ProducerList
Documentation: http://www.trafiklab.se/api/resrobot/producerlist
76 77 78 79 |
# File 'lib/samtrafiken_api/resrobot.rb', line 76 def producer_list @response = self.class.get('/ProducerList.json') return read_response @response end |
#search(query) ⇒ Hash
Endpoint: Search
Documentation: http://www.trafiklab.se/api/resrobot/search
45 46 47 48 |
# File 'lib/samtrafiken_api/resrobot.rb', line 45 def search query @response = self.class.get('/Search.json', :query => query) return read_response @response end |
#set_mode(mode) ⇒ Object
Set the API mode to use either real time or time table data.
31 32 33 34 35 36 37 |
# File 'lib/samtrafiken_api/resrobot.rb', line 31 def set_mode mode if self.class.uris.has_key? mode self.class.base_uri self.class.uris[mode] else raise "Invalid API mode." end end |
#stations_in_zone(query) ⇒ Hash
Endpoint: StationsInZone
Documentation: http://www.trafiklab.se/api/resrobot/stationsinzone
56 57 58 59 |
# File 'lib/samtrafiken_api/resrobot.rb', line 56 def stations_in_zone query @response = self.class.get('/StationsInZone.json', :query => query) return read_response @response end |
#time_table_period ⇒ Hash
Endpoint: TimeTablePeriod
Documentation: http://www.trafiklab.se/api/resrobot/timetableperiod
66 67 68 69 |
# File 'lib/samtrafiken_api/resrobot.rb', line 66 def time_table_period @response = self.class.get('/TimeTablePeriod.json') return read_response @response end |
#transport_mode_list ⇒ Hash
Endpoint: TransportModeList
Documentation: http://www.trafiklab.se/api/resrobot/transportmodelist
86 87 88 89 |
# File 'lib/samtrafiken_api/resrobot.rb', line 86 def transport_mode_list @response = self.class.get('/TransportModeList.json') return read_response @response end |