Sha256: 6340159b7371d868402b0c7da569be96ef065d0ac3f7e617dcbc88d094002e19

Contents?: true

Size: 788 Bytes

Versions: 8

Compression:

Stored size: 788 Bytes

Contents

module Ratis

  class Landmark

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

    def initialize(landmark)
      @type     = landmark[:type]
      @verbose  = landmark[:verbose]
      @location = landmark[:location]
      @locality = landmark[:locality]
    end

    def self.where(conditions)
      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', { 'Type' => type, 'Zipcode' => zipcode }

      return [] unless response.success?

      response.to_array(:getlandmarks_response, :landmark).map do |landmark|
        Landmark.new(landmark)
      end

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ratis-3.6.6 lib/ratis/landmark.rb
ratis-3.6.5 lib/ratis/landmark.rb
ratis-3.6.4 lib/ratis/landmark.rb
ratis-3.6.3 lib/ratis/landmark.rb
ratis-3.6.2 lib/ratis/landmark.rb
ratis-3.6.1 lib/ratis/landmark.rb
ratis-3.6.0 lib/ratis/landmark.rb
ratis-3.5.0 lib/ratis/landmark.rb