Module: Ipapi
- Defined in:
- lib/ipapi.rb
Constant Summary collapse
- BASE_URL =
"https://api.ipquery.io"
Class Method Summary collapse
Class Method Details
.query_ip(ip, format = "json") ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ipapi.rb', line 19 def self.query_ip(ip, format = "json") begin response = HTTParty.get("#{BASE_URL}/#{ip}?format=#{format}") if response puts response.body else puts("Error: #{response.code}") end rescue Exception => err puts("Error: #{err.message}") end end |
.query_own_ip ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ipapi.rb', line 5 def self.query_own_ip begin response = HTTParty.get(BASE_URL) if response puts response.body else puts("Error: #{response.code}") end rescue Exception => err puts("Error: #{err.message}") end end |