The gis-distance library allows you to calculate geographic distance between two points using the formula of your choice.
gem install gis-distance
gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/gis-distance/main/certs/djberg96_pub.pem)
require 'gis/distance' # or 'gis-distance'
# New York to Los Angeles
gis = GIS::Distance.new(40.47, 73.58, 34.3, 118.15)
# Set the formula of your choice
gis.formula = 'cosines'
gis.formula = 'haversine'
gis.formula = 'vincenty'
p gis.distance # Kilometers
p gis.distance.mi # Miles
http://en.wikipedia.org/wiki/Earth_radius
Ruby 2.x was dropped from the test matrix as of version 1.2 because of incompatibility with bundler. This library should still work fine with older versions of Ruby, but you should strongly consider upgrading at this point since Ruby 2.x is now EOL.
Artistic-2.0