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, original_params = {}, 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
15 16 17 |
# File 'app/models/geo_names_resource.rb', line 15 def self.find_location(location) return GeoNamesResource.find(:all, params: { q: location, username: "cam156", maxRows: 10}) end |
.instantiate_collection(collection, original_params = {}, prefix_options = {}) ⇒ Object
10 11 12 13 |
# File 'app/models/geo_names_resource.rb', line 10 def self.instantiate_collection(collection, original_params = {}, = {}) col = super(collection["geonames"], original_params, ) col.map! { |item| { label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName} } end |