Sha256: e6f46fe35d24ef76a77a907dcbf294b78736470e28c0ed7934ed6c1395cbaee9
Contents?: true
Size: 1.39 KB
Versions: 24
Compression:
Stored size: 1.39 KB
Contents
# Copyright © 2012 The Pennsylvania State University # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. 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
24 entries across 24 versions & 2 rubygems