Sha256: 1208406e93e5514c32fd0d34660c4ad0a688a082044c20403f9a0f0feadeee30

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

require 'geocoder/results/base'

module Geocoder::Result
  class Ipbase < Base
    def ip
      @data["data"]['ip']
    end

    def country_code
      @data["data"]["location"]["country"]["alpha2"]
    end

    def country
      @data["data"]["location"]["country"]["name"]
    end

    def state_code
      @data["data"]["location"]["region"]["alpha2"]
    end

    def state
      @data["data"]["location"]["region"]["name"]
    end

    def city
      @data["data"]["location"]["city"]["name"]
    end

    def postal_code
      @data["data"]["location"]["zip"]
    end

    def coordinates
      [
        @data["data"]["location"]["latitude"].to_f,
        @data["data"]["location"]["longitude"].to_f
      ]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
geocoder-1.8.3 lib/geocoder/results/ipbase.rb
geocoder-1.8.2 lib/geocoder/results/ipbase.rb
geocoder-1.8.1 lib/geocoder/results/ipbase.rb