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



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, 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