Class: IpGeolocation::Geo
- Inherits:
-
Object
- Object
- IpGeolocation::Geo
- Defined in:
- lib/ip_geolocation.rb
Instance Method Summary collapse
Instance Method Details
#ip(geo_ip) ⇒ Object
12 13 14 |
# File 'lib/ip_geolocation.rb', line 12 def ip(geo_ip) @geo_ip = geo_ip end |
#location ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ip_geolocation.rb', line 16 def location url = RestClient.get "http://ip-api.com/json/#{@geo_ip}" api1 = JSON.parse(url.body)["query"] puts "Ip: #{api1}" api2 = JSON.parse(url.body)["country"] puts "Country: #{api2}" api3 = JSON.parse(url.body)["regionName"] puts "Region: #{api3}" api4 = JSON.parse(url.body)["city"] puts "City: #{api4}" api5 = JSON.parse(url.body)["status"] puts "Status: #{api5}" end |