Created
May 14, 2017 09:16
-
-
Save kopylovvlad/5bcb1078d439434fb607d12710b37700 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class GeoCoordinate | |
# some code | |
## | |
# returns array | |
def three_nearest_coordinates | |
return [] unless @latitude.present? and @longitude.present? | |
coords_count = nearest_coordinates_count | |
case coords_count | |
when 0 | |
return [] | |
when ->(integer) { [1, 2, 3].include?(integer) } | |
nearest_coordinates.limit(coords_count) | |
else | |
nearest_coordinates.limit(3) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment