Sha256: e3abb2da7996f01f26daceb265d5427b501b2c9df76679634a3e3bc0728cd5ec

Contents?: true

Size: 844 Bytes

Versions: 9

Compression:

Stored size: 844 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)
    GeoNamesResource.find(:all, params: { q: location, username: Sufia.config.geonames_username, maxRows: 10 })
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
sufia-models-6.7.0 app/models/geo_names_resource.rb
sufia-7.0.0.beta4 app/models/geo_names_resource.rb
sufia-7.0.0.beta3 app/models/geo_names_resource.rb
sufia-7.0.0.beta2 app/models/geo_names_resource.rb
sufia-7.0.0.beta1 app/models/geo_names_resource.rb
sufia-models-6.6.1 app/models/geo_names_resource.rb
sufia-models-6.6.0 app/models/geo_names_resource.rb
sufia-models-6.5.0 app/models/geo_names_resource.rb
sufia-models-6.4.0 app/models/geo_names_resource.rb