Class: PTVApi
- Inherits:
-
Object
- Object
- PTVApi
- Defined in:
- lib/ptv_api.rb
Instance Attribute Summary collapse
-
#dev_id ⇒ Object
readonly
Returns the value of attribute dev_id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #broad_next_departures(stop, number_of_results) ⇒ Object
- #healthcheck ⇒ Object
-
#initialize(dev_id, key) ⇒ PTVApi
constructor
A new instance of PTVApi.
- #stops_near_me(location) ⇒ Object
Constructor Details
#initialize(dev_id, key) ⇒ PTVApi
Returns a new instance of PTVApi.
11 12 13 14 |
# File 'lib/ptv_api.rb', line 11 def initialize dev_id, key @dev_id = dev_id @key = key end |
Instance Attribute Details
#dev_id ⇒ Object
Returns the value of attribute dev_id.
9 10 11 |
# File 'lib/ptv_api.rb', line 9 def dev_id @dev_id end |
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/ptv_api.rb', line 9 def key @key end |
Instance Method Details
#broad_next_departures(stop, number_of_results) ⇒ Object
25 26 27 28 |
# File 'lib/ptv_api.rb', line 25 def broad_next_departures stop, number_of_results response = send_request "/v2/mode/#{stop.transport_type.id}/stop/#{stop.stop_id}/departures/by-destination/limit/#{number_of_results}" response["values"].map { |departure| Departure.new(departure) } end |
#healthcheck ⇒ Object
16 17 18 |
# File 'lib/ptv_api.rb', line 16 def healthcheck send_request "/v2/healthcheck" end |
#stops_near_me(location) ⇒ Object
20 21 22 23 |
# File 'lib/ptv_api.rb', line 20 def stops_near_me location response = send_request "/v2/nearme/latitude/#{location.lat}/longitude/#{location.long}" response.map { |result| Stop.new(result["result"]) } end |