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
really-broken-geocoder-1.5.1 lib/geocoder/results/ipapi_com.rb
geocoder-1.5.1 lib/geocoder/results/ipapi_com.rb
geocoder-1.5.0 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.9 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.8 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.7 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.6 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.5 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.4 lib/geocoder/results/ipapi_com.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/geocoder-1.4.3/lib/geocoder/results/ipapi_com.rb
geocoder-1.4.3 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.2 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.1 lib/geocoder/results/ipapi_com.rb
geocoder-1.4.0 lib/geocoder/results/ipapi_com.rb
geocoder-1.3.7 lib/geocoder/results/ipapi_com.rb
geocoder-1.3.6 lib/geocoder/results/ipapi_com.rb
geocoder-1.3.5 lib/geocoder/results/ipapi_com.rb
broken-geocoder-1.3.6 lib/geocoder/results/ipapi_com.rb
broken-geocoder-1.3.5 lib/geocoder/results/ipapi_com.rb
broken-geocoder-1.3.4 lib/geocoder/results/ipapi_com.rb