Skip to content

Instantly share code, notes, and snippets.

@rbenigno
Created February 21, 2012 16:52
Show Gist options
  • Save rbenigno/1877347 to your computer and use it in GitHub Desktop.
Save rbenigno/1877347 to your computer and use it in GitHub Desktop.
Use hostapi.info to get the public IP of a system
require "httparty"
class IPinfo
include HTTParty
base_uri('api.hostip.info')
format :xml
def self.public()
response = get('/').parsed_response
response["HostipLookupResultSet"]["featureMember"]["Hostip"]["ip"]
end
end
# get current ip
puts IPinfo.public
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment