Class: Bikes
Constant Summary collapse
- STATIONS_URL =
'https://api.jcdecaux.com/vls/v1/stations'
- CONTRACTS_URL =
'https://api.jcdecaux.com/vls/v1/contracts'
Instance Method Summary collapse
- #contracts ⇒ Object
- #contracts_fetch ⇒ Object
-
#initialize(apikey, scheme) ⇒ Bikes
constructor
A new instance of Bikes.
- #station(num) ⇒ Object
- #stations ⇒ Object
- #stations_fetch ⇒ Object
Constructor Details
#initialize(apikey, scheme) ⇒ Bikes
Returns a new instance of Bikes.
13 14 15 16 17 18 19 20 21 |
# File 'lib/bikes.rb', line 13 def initialize(apikey, scheme) @api = apikey @scheme = scheme # Contracts refresh daily @contracts_cache = Cache.new(self, :contracts_fetch) # Full stations list refresh every 60 seconds @stations_cache = Cache.new(self, :stations_fetch, 60) end |
Instance Method Details
#contracts ⇒ Object
27 28 29 |
# File 'lib/bikes.rb', line 27 def contracts @contracts_cache.contents end |
#contracts_fetch ⇒ Object
31 32 33 |
# File 'lib/bikes.rb', line 31 def contracts_fetch invoke(CONTRACTS_URL) end |
#station(num) ⇒ Object
23 24 25 |
# File 'lib/bikes.rb', line 23 def station(num) invoke(STATIONS_URL + '/' + num.to_s, {contract: @scheme}) end |
#stations ⇒ Object
35 36 37 |
# File 'lib/bikes.rb', line 35 def stations @stations_cache.contents end |
#stations_fetch ⇒ Object
39 40 41 |
# File 'lib/bikes.rb', line 39 def stations_fetch invoke(STATIONS_URL, { contract: @scheme }) end |