Class: GeoNamesResource

Inherits:
ActiveResource::Base
  • Object
show all
Defined in:
app/models/geo_names_resource.rb

Class Method Summary collapse

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(prefix_options = {}, query_options = nil)
  super(prefix_options, query_options).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)
  GeoNamesResource.find(:all, params: { q: location, username: Sufia.config.geonames_username, 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 = {}, 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