Sha256: 8a487d08c34a2f71f97e5ce5b0bd2df3d68c1f2e0c1f10ff2d33a0ba9d23f520

Contents?: true

Size: 823 Bytes

Versions: 34

Compression:

Stored size: 823 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, 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

34 entries across 34 versions & 2 rubygems

Version Path
sufia-models-3.7.1 app/models/geo_names_resource.rb
sufia-3.7.1 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.7.0 app/models/geo_names_resource.rb
sufia-3.7.0 sufia-models/app/models/geo_names_resource.rb
sufia-3.6.1 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.6.1 app/models/geo_names_resource.rb
sufia-3.6.0 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.6.0 app/models/geo_names_resource.rb
sufia-3.5.0 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.5.0 app/models/geo_names_resource.rb
sufia-3.4.0 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.4.0 app/models/geo_names_resource.rb
sufia-3.4.0.rc4 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.4.0.rc4 app/models/geo_names_resource.rb
sufia-3.4.0.rc3 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.4.0.rc3 app/models/geo_names_resource.rb
sufia-3.3.1 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.3.1 app/models/geo_names_resource.rb
sufia-3.4.0.rc2 sufia-models/app/models/geo_names_resource.rb
sufia-models-3.4.0.rc2 app/models/geo_names_resource.rb