Created
September 17, 2009 20:57
-
-
Save jferris/188706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GeoKit | |
module Geocoders | |
class FakeGeocoder < Geocoder | |
def self.locations | |
@locations ||= {} | |
end | |
def self.geocode(location) | |
loc = GeoLoc.new | |
if locations.key?(location) | |
loc.lat, loc.lng = *locations.fetch(location) | |
loc.success = true | |
end | |
loc | |
end | |
def self.[](key) | |
locations[key] | |
end | |
def self.[]=(key, value) | |
locations[key] = value | |
end | |
def self.clear | |
locations.clear | |
end | |
def self.add_location_away_from(origin, options) | |
bounds = GeoKit::Bounds.from_point_and_radius(origin, options[:distance]) | |
locations.store(options[:location], [bounds.sw.lat, bounds.center.lng]) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment