Skip to content
Snippets Groups Projects
Commit 03b8f247 authored by Alex Reisner's avatar Alex Reisner
Browse files

Add to_miles and to_kilometers methods.

parent d5e62b26
No related branches found
No related tags found
No related merge requests found
......@@ -158,12 +158,25 @@ module Geocoder
end
end
##
# Convert miles to kilometers.
#
def to_kilometers(mi)
mi * mi_in_km
end
##
# Convert kilometers to miles.
#
def to_miles(km)
km * km_in_mi
end
##
# Radius of the Earth in the given units (:mi or :km). Default is :mi.
#
def earth_radius(units = :mi)
in_km = EARTH_RADIUS
units == :km ? in_km : in_km * km_in_mi
units == :km ? EARTH_RADIUS : to_miles(EARTH_RADIUS)
end
##
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment