Class: GeoNamesResource
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- GeoNamesResource
- Defined in:
- app/models/geo_names_resource.rb
Class Method Summary collapse
- .collection_path(prefix_options = {}, query_options = nil) ⇒ Object
- .find_location(location) ⇒ Object
- .instantiate_collection(collection, prefix_options = {}) ⇒ Object
Class Method Details
.collection_path(prefix_options = {}, query_options = nil) ⇒ Object
6 7 8 |
# File 'app/models/geo_names_resource.rb', line 6 def self.collection_path( = {}, = nil) super(, ).gsub(/\.json|\.xml/, "") end |
.find_location(location) ⇒ Object
16 17 18 |
# File 'app/models/geo_names_resource.rb', line 16 def self.find_location(location) return GeoNamesResource.find(:all, :params => { :q =>location, :username=>"cam156", :maxRows=>10}) end |
.instantiate_collection(collection, prefix_options = {}) ⇒ Object
10 11 12 13 14 |
# File 'app/models/geo_names_resource.rb', line 10 def self.instantiate_collection(collection, = {}) col = super(collection["geonames"],) col.map! {|item| { label: item.name+ (item.adminName1 ? ", " + item.adminName1 : "")+", " + item.countryName, value: item.name+ (item.adminName1 ? ", " + item.adminName1 : "")+", " + item.countryName} } return col end |