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