Sha256: c04de38bdaa30e7408e2bf4c1edc55ce550022348995900820e590be33a2b7d5

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

require 'httparty'
require 'ipaddress'


module Moocher
  module GeoIp
    def geolocate_ip(ipaddress)
      return "IP Address doesn't seem to be valid." if !(IPAddress.valid? ipaddress)
      base_url = 'https://api.moocher.io/ip/'
      response = HTTParty.get(base_url + ipaddress)
      if response.success?
        response.parsed_response
      else
        "Sorry No data was found."
      end
    end

    def geolocate_my_ip
      base_url = 'https://api.moocher.io/ip'
      response = HTTParty.get(base_url)
      if response.success?
        response.parsed_response
      else
        "Sorry No data was found."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moocher-0.1.1.6pre lib/moocher/geo_ip.rb