Class: Geo
- Inherits:
-
Object
- Object
- Geo
- Defined in:
- lib/meteo/geo.rb
Constant Summary collapse
- GEO_LOCATION_SERVICE_URL =
"http://freegeoip.net/json/"
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize ⇒ Geo
constructor
A new instance of Geo.
- #quote(ip_address = nil) ⇒ Object
Constructor Details
#initialize ⇒ Geo
Returns a new instance of Geo.
9 10 11 |
# File 'lib/meteo/geo.rb', line 9 def initialize @url = GEO_LOCATION_SERVICE_URL end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/meteo/geo.rb', line 7 def url @url end |
Instance Method Details
#quote(ip_address = nil) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/meteo/geo.rb', line 13 def quote ip_address=nil quote_url = ip_address ? "#{url}#{ip_address}" : url uri = URI.parse(URI.escape(quote_url)) JSON.parse(Net::HTTP.get(uri)) end |