Skip to content

Commit

Permalink
Just some styling fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
elifoster committed Oct 22, 2015
1 parent eaccb0c commit 61b71a4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/simple_geolocator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
require 'json'

module SimpleGeolocator
extend self
module_function

@client = HTTPClient.new

# Gets the full JSON response, useful for getting multiple pieces of data in
Expand All @@ -13,7 +14,7 @@ def get_full_response(ip)
url = "http://ip-api.com/json/#{ip}"
uri = URI.parse(url)
response = @client.get(uri)
return JSON.parse(response.body)
JSON.parse(response.body)
end

# Gets whether the request failed or not.
Expand All @@ -36,8 +37,8 @@ def country(ip)
response = get_full_response(ip)
if request_successful?(response)
ret = {
:name => response['country'],
:code => response['countryCode']
name: response['country'],
code: response['countryCode']
}
return ret
else
Expand All @@ -53,8 +54,8 @@ def region(ip)
response = get_full_response(ip)
if request_successful?(response)
ret = {
:name => response['regionName'],
:code => response['region']
name: response['regionName'],
code: response['region']
}
return ret
else
Expand Down Expand Up @@ -140,7 +141,8 @@ def organization_name(ip)
end

private

def error(response)
return response['message']
response['message']
end
end

0 comments on commit 61b71a4

Please sign in to comment.