class Location
Attributes
ip[RW]
zip[RW]
Public Class Methods
new()
click to toggle source
# File lib/locator.rb, line 9 def initialize @ip = get_ip @zip = get_zip end
Public Instance Methods
get_ip()
click to toggle source
# File lib/locator.rb, line 14 def get_ip html = open('http://ipecho.net/') noko = Nokogiri::HTML(html) noko.search('h1').text.gsub("Your IP is ", "") end
get_zip()
click to toggle source
# File lib/locator.rb, line 20 def get_zip Geocoder.search(@ip)[0].data["zip_code"] end