Class: Ratis::NextBus2
- Inherits:
-
Object
- Object
- Ratis::NextBus2
- Defined in:
- lib/ratis/next_bus2.rb
Overview
This method returns the time of the next vehicles at a location based on TA ID or ATIS stop ID only. The date and time of the query are “today” and “now.” The response is a subset of the data returned by the Nextbus method.
Instance Attribute Summary collapse
-
#runs ⇒ Object
Returns the value of attribute runs.
-
#stops ⇒ Object
Returns the value of attribute stops.
Class Method Summary collapse
-
.where(conditions) ⇒ NextBus
Returns results of NextBus query containing arrays of stops and runs.
Instance Method Summary collapse
-
#initialize(response) ⇒ NextBus
constructor
Initializes a NextBus object with stops and runs.
-
#to_hash_for_xml ⇒ Object
Details of NextBus instance in a hash to be transformed to xml.
Constructor Details
#initialize(response) ⇒ NextBus
Initializes a NextBus object with stops and runs.
Parameters:
- stops
-
Optional - An array of stops. Defaults to empty array.
- runs
-
Optional - An array of runs. Defaults to empty array.
19 20 21 22 |
# File 'lib/ratis/next_bus2.rb', line 19 def initialize(response) @stops = response.to_array :nextbus2_response, :stops, :stop @runs = response.to_array :nextbus2_response, :runs, :run end |
Instance Attribute Details
#runs ⇒ Object
Returns the value of attribute runs.
7 8 9 |
# File 'lib/ratis/next_bus2.rb', line 7 def runs @runs end |
#stops ⇒ Object
Returns the value of attribute stops.
7 8 9 |
# File 'lib/ratis/next_bus2.rb', line 7 def stops @stops end |
Class Method Details
.where(conditions) ⇒ NextBus
Returns results of NextBus query containing arrays of stops and runs.
Parameters:
Takes hash of conditions
- option1
-
Required - Description of required param
- option2
-
Optional - Description of optional param
- option3
-
Optional - Description of optional param
- option4
-
Optional - Description of optional param
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ratis/next_bus2.rb', line 40 def self.where(conditions) stop_id = conditions.delete :stop_id raise ArgumentError.new('You must provide a stop ID') unless stop_id Ratis.all_conditions_used? conditions response = Request.get 'Nextbus2', { 'Stopid' => stop_id } return [] unless response.success? NextBus2.new(response) end |
Instance Method Details
#to_hash_for_xml ⇒ Object
Details of NextBus instance in a hash to be transformed to xml
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ratis/next_bus2.rb', line 54 def to_hash_for_xml raise 'Not yet implemented' { :stopname => first_stop_description, :runs => runs.map do |run| { :time => run[:estimatedtime], :scheduled_time => run[:triptime], :sign => run[:sign], :adherence => run[:adherence], :route => run[:route] } end } end |