Sha256: 8a487d08c34a2f71f97e5ce5b0bd2df3d68c1f2e0c1f10ff2d33a0ba9d23f520
Contents?: true
Size: 823 Bytes
Versions: 34
Compression:
Stored size: 823 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, prefix_options = {}) col = super(collection["geonames"],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
34 entries across 34 versions & 2 rubygems