Ruby library for Geonames Web Services (http://www.geonames.org/export/)
The Geonames API has been forked and now is maintained here: https://github.com/elecnix/ruby-geonames>
Inspired by the Geonames Java Client API library
Install from the command line
# gem install geonames
The following exercises several of the Geonames web services, full list of services listed here: http://www.geonames.org/export/
Load the the geonames API
require 'geonames'get list of places near by longitude/longitude location
places_nearby = Geonames::WebService.find_nearby_place_name 43.900120387, -78.882869834 p places_nearbyget timezone for longitude/longitude location
timezone = Geonames::WebService.timezone 43.900120387, -78.882869834 p timezoneget country code for longitude/longitude location
country_code = Geonames::WebService.country_code 43.900120387, -78.882869834 p country_codeget country sub-division info for longitude/longitude location
country_subdivision = Geonames::WebService.country_subdivision 43.900120387, -78.882869834 p country_subdivisionget postal codes for a given location
postal_code_sc = Geonames::PostalCodeSearchCriteria.new postal_code_sc.place_name = "Oshawa" postal_codes = Geonames::WebService.postal_code_search postal_code_sc p postal_codesget nearby postal codes for a place name
postal_code_sc = Geonames::PostalCodeSearchCriteria.new postal_code_sc.place_name = "Oshawa" postal_codes_nearby = Geonames::WebService.find_nearby_postal_codes postal_code_sc p postal_codes_nearby