Module: Metromobilite::Times
- Defined in:
- lib/metromobilite/times.rb
Constant Summary collapse
- RECORDS_URI =
'/ficheHoraires/json'
- LIVE_URI =
'/routers/default/index/stops/%s/stoptimes'
Class Method Summary collapse
-
.readStop(stopId) ⇒ Object
Reads the next stop times at a stop, eventually for a given route Returns an array of Metromobilite::Model::Stop with their associated stop times.
Class Method Details
.readStop(stopId) ⇒ Object
Reads the next stop times at a stop, eventually for a given route Returns an array of Metromobilite::Model::Stop with their associated stop times
stopId_string
-
the stop id
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/metromobilite/times.rb', line 18 def self.readStop(stopId) uri = LIVE_URI % stopId.to_s jsonData = Metromobilite::Request.get(uri) res = [] jsonData.each do |item| pattern = Metromobilite::Model::Pattern.new(item['pattern']) times = [] item['times'].each do |timeJson| times.push(Metromobilite::Model::Time.new timeJson) end res.push(Metromobilite::Model::Stop.new pattern, times) end return res end |