Sha256: e762522996b03ee099281d9be9aec8f915eff07de78ed9936f45544774276dd7

Contents?: true

Size: 1018 Bytes

Versions: 3

Compression:

Stored size: 1018 Bytes

Contents

module Ratis

  class Landmark

    attr_accessor :type, :verbose, :location, :locality

    def self.where(conditions)
      app_id  = conditions.delete(:app_id)      || 'WEB'
      type    = conditions.delete(:type).to_s.upcase
      zipcode = conditions.delete(:zipcode)

      raise ArgumentError.new('You must provide a type') if type.blank?
      Ratis.all_conditions_used? conditions

      response = Request.get 'Getlandmarks', {'Appid'   => app_id,
                                              'Type'    => type,
                                              'Zipcode' => zipcode}

      return [] unless response.success?

      response.to_array(:getlandmarks_response, :landmark).map do |landmark|
        atis_landmark          = Landmark.new
        atis_landmark.type     = landmark[:type]
        atis_landmark.verbose  = landmark[:verbose]
        atis_landmark.location = landmark[:location]
        atis_landmark.locality = landmark[:locality]
        atis_landmark
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ratis-3.4.1 lib/ratis/landmark.rb
ratis-3.4.0 lib/ratis/landmark.rb
ratis-3.3.7 lib/ratis/landmark.rb