Sha256: d74fa11720497ac9720c26831b01684606e4f975769d9bbb3ee1c16ca1e8ab22

Contents?: true

Size: 739 Bytes

Versions: 40

Compression:

Stored size: 739 Bytes

Contents

require 'geocoder/results/base'

module Geocoder::Result
  class IpapiCom < Base

    def coordinates
      [lat, lon]
    end

    def address
      "#{city}, #{state_code} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
    end

    def state
      region_name
    end

    def state_code
      region
    end

    def postal_code
      zip
    end

    def country_code
      @data['countryCode']
    end

    def region_name
      @data['regionName']
    end

    def self.response_attributes
      %w[country region city zip timezone isp org as reverse query status message mobile proxy lat lon]
    end

    response_attributes.each do |attribute|
      define_method attribute do
        @data[attribute]
      end
    end

  end
end

Version data entries

40 entries across 40 versions & 4 rubygems

Version Path
geocoder-1.8.3 lib/geocoder/results/ipapi_com.rb
geocoder-1.8.2 lib/geocoder/results/ipapi_com.rb
geocoder-1.8.1 lib/geocoder/results/ipapi_com.rb
geocoder-1.8.0 lib/geocoder/results/ipapi_com.rb
geocoder-1.7.5 lib/geocoder/results/ipapi_com.rb
geocoder-1.7.4 lib/geocoder/results/ipapi_com.rb
geocoder-1.7.3 lib/geocoder/results/ipapi_com.rb
geocoder-1.7.2 lib/geocoder/results/ipapi_com.rb
geocoder-1.7.1 lib/geocoder/results/ipapi_com.rb
geocoder-1.7.0 lib/geocoder/results/ipapi_com.rb
geocoder-1.6.7 lib/geocoder/results/ipapi_com.rb
geocoder-1.6.6 lib/geocoder/results/ipapi_com.rb
geocoder-1.6.5 lib/geocoder/results/ipapi_com.rb
geocoder-1.6.4 lib/geocoder/results/ipapi_com.rb
geocoder-1.6.3 lib/geocoder/results/ipapi_com.rb
geocoder-1.6.2 lib/geocoder/results/ipapi_com.rb
geocoder-1.6.1 lib/geocoder/results/ipapi_com.rb
geocoder-1.6.0 lib/geocoder/results/ipapi_com.rb
geocoder-1.5.2 lib/geocoder/results/ipapi_com.rb
really-broken-geocoder-2.0.0 lib/geocoder/results/ipapi_com.rb