Class: IPGeolocation::BlogamaLocator
- Inherits:
-
Object
- Object
- IPGeolocation::BlogamaLocator
- Defined in:
- lib/ipgeolocation.rb
Overview
Location interface for blogama.org. Doesn’t need to be used directly.
Constant Summary collapse
- BLOGAMA_QUERY_URL =
"http://blogama.org/ip_query.php?"
Class Method Summary collapse
Class Method Details
.locate(ip) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ipgeolocation.rb', line 95 def self.locate ip doc = REXML::Document.new(open(IPGeolocation::BlogamaLocator::BLOGAMA_QUERY_URL+"ip=#{ip}&output=xml")) root = doc.root puts root result = IPGeolocation::Location.new result.ip = root.elements["Ip"].text result.country_code = root.elements["CountryCode"].text result.country_name = root.elements["CountryName"].text result.region_code = root.elements["RegionCode"].text result.region_name = root.elements["RegionName"].text result.city = root.elements["City"].text result.postal_code = root.elements["ZipPostalCode"].text result.latitude = root.elements["Latitude"].text result.longitude = root.elements["Longitude"].text result end |