lib/ratis/next_bus.rb in ratis-3.1.6 vs lib/ratis/next_bus.rb in ratis-3.1.7
- old
+ new
@@ -93,48 +93,25 @@
def success?
@success
end
- # Gets description of first stop
- # @return [String] Description of first stop or nil.
+ # Used to create an XML response for the NextBus SMS services which hits
+ # /nextride.xml?stop_id=<STOPID>
- def first_stop_description
- raise 'Not yet implemented'
- stops.first ? stops.first[:description] : nil
- end
+ def to_hash_for_xml
+ { :stopname => @stop[:description],
+ :runs => @services.map do |service|
+ service.trips.map do |trip|
- # Details of NextBus instance in a hash.
- # @return [Hash] NextBus details in a hash.
+ { :time => trip.realtime.estimatedtime,
+ :sign => trip.realtime.sign,
+ :adherence => trip.realtime.adherence,
+ :route => trip.realtime.route
+ }
+ end
+ end.flatten
- def to_hash
- raise 'Not yet implemented'
- { :stopname => first_stop_description,
- :signs => runs.map { |run| run[:sign] }.uniq,
- :runs => runs.map do |run|
- { :time => run[:estimatedtime],
- :sign => run[:sign],
- :adherence => run[:adherence],
- :route => run[:route]
- }
- end
- }
- end
-
- # Details of NextBus instance in a hash to be transformed to xml
- # @private
-
- 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
end
end