Sha256: f9146d77305051fd8c984e6719e73fdebd7dd54268b22657e45b0be1f9a6cba2

Contents?: true

Size: 1021 Bytes

Versions: 14

Compression:

Stored size: 1021 Bytes

Contents

module Ratis
  class ClosestStop

    def self.where(conditions)
      latitude      = conditions.delete :latitude
      longitude     = conditions.delete :longitude
      location_text = conditions.delete :location_text
      num_stops     = conditions.delete :num_stops

      raise ArgumentError.new('You must provide a longitude') unless longitude
      raise ArgumentError.new('You must provide a latitude')  unless latitude

      Ratis.all_conditions_used? conditions

      response = Request.get 'Closeststop',
                             {'Locationlat'  => latitude,
                              'Locationlong' => longitude,
                              'Locationtext' => location_text,
                              'Numstops'     => num_stops }

      return [] unless response.success?

      stops = response.to_hash[:closeststop_response][:stops][:stop].map do |stop|
                next if stop[:description].blank?

                Ratis::Stop.new(stop)
              end.compact
    end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ratis-3.6.6 lib/ratis/closest_stop.rb
ratis-3.6.5 lib/ratis/closest_stop.rb
ratis-3.6.4 lib/ratis/closest_stop.rb
ratis-3.6.3 lib/ratis/closest_stop.rb
ratis-3.6.2 lib/ratis/closest_stop.rb
ratis-3.6.1 lib/ratis/closest_stop.rb
ratis-3.6.0 lib/ratis/closest_stop.rb
ratis-3.5.0 lib/ratis/closest_stop.rb
ratis-3.4.3 lib/ratis/closest_stop.rb
ratis-3.4.2 lib/ratis/closest_stop.rb
ratis-3.4.1 lib/ratis/closest_stop.rb
ratis-3.4.0 lib/ratis/closest_stop.rb
ratis-3.3.7 lib/ratis/closest_stop.rb
ratis-3.3.6 lib/ratis/closest_stop.rb