Sha256: a28e4eac3d56dd405b06b502f867b052c70d44ad1b86c9f60dafabf360850930

Contents?: true

Size: 316 Bytes

Versions: 1

Compression:

Stored size: 316 Bytes

Contents

require "ip2l/version"
require 'net/http'
require 'json'

module Ip2l
  class Ip2l
    def ip_to_location(ip)
      uri = URI("http://pytool.sinaapp.com/geo?type=json&pos=1&encoding=utf-8&ip=%s" % ip)
      content = Net::HTTP.get(uri)
      result = JSON.parse(content)
      result["geo"]["loc"]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ip2l-0.1.0 lib/ip2l.rb