Sha256: 0955d01fba34a2fe43067358f2501e7a0d61d27041a6e3f09dc0cc79db3ad090
Contents?: true
Size: 831 Bytes
Versions: 37
Compression:
Stored size: 831 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} } end def self.find_location(location) return GeoNamesResource.find(:all, params: { q: location, username: "cam156", maxRows: 10}) end end
Version data entries
37 entries across 37 versions & 2 rubygems