Sha256: 609ba88885f0049c42f2aa21fadc51d2a89d61bfd0e24553e90ddfe852a654d6
Contents?: true
Size: 850 Bytes
Versions: 2
Compression:
Stored size: 850 Bytes
Contents
require 'active_resource' 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
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
sufia-3.0.0 | sufia-models/app/models/geo_names_resource.rb |
sufia-models-3.0.0 | app/models/geo_names_resource.rb |