Created
February 21, 2012 16:52
-
-
Save rbenigno/1877347 to your computer and use it in GitHub Desktop.
Use hostapi.info to get the public IP of a system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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