Class: Transprt::Client
- Inherits:
-
Object
- Object
- Transprt::Client
- Defined in:
- lib/transprt/client.rb
Constant Summary collapse
- DEFAULT_DOMAIN =
'http://transport.opendata.ch'.freeze
- VERSION =
'v1'.freeze
Instance Method Summary collapse
-
#connections(parameters) ⇒ Object
> find connections.
-
#initialize(domain = DEFAULT_DOMAIN, version = VERSION) ⇒ Client
constructor
A new instance of Client.
-
#locations(parameters) ⇒ Object
> find locations.
-
#stationboard(parameters) ⇒ Object
> find station boards.
Constructor Details
#initialize(domain = DEFAULT_DOMAIN, version = VERSION) ⇒ Client
Returns a new instance of Client.
12 13 14 15 |
# File 'lib/transprt/client.rb', line 12 def initialize(domain = DEFAULT_DOMAIN, version = VERSION) @domain = domain @version = version end |
Instance Method Details
#connections(parameters) ⇒ Object
> find connections
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/transprt/client.rb', line 32 def connections(parameters) allowed_parameters = %w(from to via date time isArrivalTime transportations limit page direct sleeper couchette bike) query = create_query(parameters, allowed_parameters) locations = perform('connections', query) locations['connections'] end |
#locations(parameters) ⇒ Object
> find locations
20 21 22 23 24 25 26 27 |
# File 'lib/transprt/client.rb', line 20 def locations(parameters) allowed_parameters = %w(query x y type) query = create_query(parameters, allowed_parameters) locations = perform('locations', query) locations['stations'] end |
#stationboard(parameters) ⇒ Object
> find station boards
46 47 48 49 50 51 52 53 |
# File 'lib/transprt/client.rb', line 46 def stationboard(parameters) allowed_parameters = %w(station id limit transportations datetime) query = create_query(parameters, allowed_parameters) locations = perform('stationboard', query) locations['stationboard'] end |