Skip to content

Instantly share code, notes, and snippets.

@jferris
Created September 17, 2009 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jferris/188706 to your computer and use it in GitHub Desktop.
Save jferris/188706 to your computer and use it in GitHub Desktop.
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