Sha256: 1c24fb156d0713a2d11d88ba755d7f50f626e1ab6a1484c1c8444b9f3b341c4a
Contents?: true
Size: 861 Bytes
Versions: 6
Compression:
Stored size: 861 Bytes
Contents
class GeoNamesResource < ActiveResource::Base self.site = "http://api.geonames.org/" self.element_name = "searchJSON" self.collection_name = "searchJSON" def self.collection_path(prefix_options = {}, query_options = nil) super(prefix_options, query_options).gsub(/\.json|\.xml/, "") end def self.instantiate_collection(collection, original_params = {}, prefix_options = {}) col = super(collection["geonames"], original_params, prefix_options) col.map! {|item| { label: item.name+ (item.adminName1 ? ", " + item.adminName1 : "")+", " + item.countryName, value: item.name+ (item.adminName1 ? ", " + item.adminName1 : "")+", " + item.countryName} } return col end def self.find_location(location) return GeoNamesResource.find(:all, :params => { :q =>location, :username=>"cam156", :maxRows=>10}) end end
Version data entries
6 entries across 6 versions & 2 rubygems