Class: Tramtracker::API

Inherits:
Object
  • Object
show all
Defined in:
lib/tramtracker/api.rb

Constant Summary collapse

DATE_FORMAT =
"/Date(%Q%z)/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stop_id) ⇒ API

Returns a new instance of API.



10
11
12
# File 'lib/tramtracker/api.rb', line 10

def initialize(stop_id)
  @stop_id = stop_id
end

Instance Attribute Details

#stop_idObject

Returns the value of attribute stop_id.



8
9
10
# File 'lib/tramtracker/api.rb', line 8

def stop_id
  @stop_id
end

Instance Method Details

#getObject



14
15
16
17
18
19
20
21
# File 'lib/tramtracker/api.rb', line 14

def get
  api_response["responseObject"].collect do |tram|
    {
      route: tram["RouteNo"],
      minutes: minutes_until(tram["PredictedArrivalDateTime"])
    }
  end
end