Created
March 6, 2017 02:11
-
-
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
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 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