Class: Graticule::Geocoder::HostIp
- Inherits:
-
Object
- Object
- Graticule::Geocoder::HostIp
- Defined in:
- lib/graticule/geocoder/host_ip.rb
Instance Method Summary collapse
-
#initialize ⇒ HostIp
constructor
A new instance of HostIp.
-
#locate(address) ⇒ Object
Geocode an IP address using hostip.info.
Constructor Details
#initialize ⇒ HostIp
Returns a new instance of HostIp.
8 9 10 |
# File 'lib/graticule/geocoder/host_ip.rb', line 8 def initialize @url = URI.parse 'http://api.hostip.info/get_html.php' end |
Instance Method Details
#locate(address) ⇒ Object
Geocode an IP address using hostip.info
13 14 15 16 17 18 19 20 |
# File 'lib/graticule/geocoder/host_ip.rb', line 13 def locate(address) make_url(:ip => address, :position => true).open do |response| # add new line so YAML.load doesn't puke result = response.read + "\n" check_error(result) parse_response(YAML.load(result)) end end |