Skip to content

Instantly share code, notes, and snippets.

@clockworkpc
Created March 6, 2017 02:11
Show Gist options
  • Save clockworkpc/c0a27f167dd5a696dcbc443854fff628 to your computer and use it in GitHub Desktop.
Save clockworkpc/c0a27f167dd5a696dcbc443854fff628 to your computer and use it in GitHub Desktop.
City Grid with Positive and Negative Values for X and Y Coördinates
module CityNavigation
class CityGrid
def initialize(latitude, longitude)
@latitude = latitude
@longitude = longitude
end
def valid_location?(east, north)
(-@latitude...@latitude).cover?(east)
(-@latitude...@latitude).cover?(-east)
(-@longitude...@longitude).cover?(north)
(-@longitude...@longitude).cover?(-north)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment