Class: Graticule::Geocoder::Geonames

Inherits:
Base
  • Object
show all
Defined in:
lib/graticule/geocoder/geonames.rb

Defined Under Namespace

Classes: Response, Status

Constant Summary

Constants inherited from Base

Base::USER_AGENT

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ Geonames

Returns a new instance of Geonames.


6
7
8
9
# File 'lib/graticule/geocoder/geonames.rb', line 6

def initialize(username)
  @url = URI.parse('http://ws.geonames.org/timezone')
  @username = URI.encode(username)
end

Instance Method Details

#time_zone(location) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/graticule/geocoder/geonames.rb', line 11

def time_zone(location)
  get :formatted => 'true', 
      :style => 'full',
      :lat => location.latitude,
      :lng => location.longitude,
      :username => @username
end