Module: KVVLiveAPI

Defined in:
lib/kvvliveapi.rb,
lib/kvvliveapi/stop.rb,
lib/kvvliveapi/version.rb,
lib/kvvliveapi/depature.rb,
lib/kvvliveapi/constants.rb

Overview

Main module for accessing the KVV live API. All API functions can be called directly on the class object.

Defined Under Namespace

Classes: Departure, Stop

Constant Summary collapse

VERSION =

Currently installed version of the Gem

'0.1.1'.freeze
API_KEY =

Publicly available key needed to access the API

'377d840e54b59adbe53608ba1aad70e8'.freeze
API_BASE =

Base URL for all API calls

'https://live.kvv.de/webapp/'.freeze

Class Method Summary collapse

Class Method Details

.depatures_by_route(route, stop_id) ⇒ Object

Retrieves a list of upcoming depatures for a specified rouute at a specified Stop ID

  • route - Route for which upcoming depatures should be retrieved

  • stop_id - ID of the Stop for which upcoming depatures should be retrieved



54
55
56
# File 'lib/kvvliveapi.rb', line 54

def depatures_by_route(route, stop_id)
  departures('departures/byroute/' + CGI.escape(route) + '/' + CGI.escape(stop_id))
end

.depatures_by_stop(stop_id) ⇒ Object

Retrieves a list of upcoming depatures for a specified Stop ID

  • stop_id - ID of the Stop for which upcoming depatures should

be retrieved



44
45
46
# File 'lib/kvvliveapi.rb', line 44

def depatures_by_stop(stop_id)
  departures('departures/bystop/' + stop_id)
end

.stops_by_coordinates(lat, lon) ⇒ Object

Retrieves a list of stops close to a given set of coordinates

  • lat - latitude

  • long - longitude



29
30
31
# File 'lib/kvvliveapi.rb', line 29

def stops_by_coordinates(lat, lon)
  stops('stops/bylatlon/' + ('%.6f' % lat) + '/' + ('%.6f' % lon))
end

.stops_by_id(stop_id) ⇒ Object

Retrieves a single stop object by its ID

  • stop_id - ID of the Stop to retrieve



36
37
38
# File 'lib/kvvliveapi.rb', line 36

def stops_by_id(stop_id)
  [Stop.from_json(query('stops/bystop/' + CGI.escape(stop_id)))]
end

.stops_by_name(name) ⇒ Object

Retrieves a list of stops whose names match a given string

  • name - name or fragment of the name of the Stop that is searched



21
22
23
# File 'lib/kvvliveapi.rb', line 21

def stops_by_name(name)
  stops('stops/byname/' + CGI.escape(name))
end