lib/ratis/schedule_nearby.rb in ratis-2.5.2.8 vs lib/ratis/schedule_nearby.rb in ratis-3.0.0

- old
+ new

@@ -3,36 +3,45 @@ class ScheduleNearby attr_accessor :atstops def self.where(conditions) - latitude = conditions.delete :latitude - longitude = conditions.delete :longitude - date = conditions.delete :date - time = conditions.delete :time - window = conditions.delete :window - walk_distance = conditions.delete :walk_distance - landmark_id = conditions.delete :landmark_id - stop_id = conditions.delete(:stop_id) || '' - app_id = conditions.delete(:app_id) || 'na' + latitude = conditions.delete(:latitude) + longitude = conditions.delete(:longitude) + date = conditions.delete(:date) + time = conditions.delete(:time) + window = conditions.delete(:window) + walk_distance = conditions.delete(:walk_distance) + landmark_id = conditions.delete(:landmark_id) + stop_id = conditions.delete(:stop_id) || '' + app_id = conditions.delete(:app_id) || 'na' raise ArgumentError.new('You must provide latitude') unless latitude raise ArgumentError.new('You must provide longitude') unless longitude raise ArgumentError.new('You must provide date') unless date raise ArgumentError.new('You must provide time') unless time raise ArgumentError.new('You must provide window') unless window raise ArgumentError.new('You must provide walk_distance') unless walk_distance raise ArgumentError.new('You must provide landmark_id') unless landmark_id + Ratis.all_conditions_used? conditions response = Request.get 'Schedulenearby', - {'Locationlat' => latitude, 'Locationlong' => longitude, - 'Date' => date, 'Time' => time, 'Window' => window, 'Walkdist' => walk_distance, - 'Landmarkid' => landmark_id, 'Stopid' => stop_id, 'Appid' => app_id - } + {'Locationlat' => latitude, + 'Locationlong' => longitude, + 'Date' => date, + 'Time' => time, + 'Window' => window, + 'Walkdist' => walk_distance, + 'Landmarkid' => landmark_id, + 'Stopid' => stop_id, + 'Appid' => app_id + } return [] unless response.success? + # TODO: where is this nightmare-ish hash being used? + # need to refactor this into something more OO atstops = response.to_array :schedulenearby_response, :atstop atstops.map do |atstop| atstop[:services] = atstop.to_array :service atstop[:services].map do |service|