Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tkrajcar/master
Update gemfile for modern versions of development gems, and add nautical miles support
- Loading branch information
Showing
7 changed files
with
91 additions
and
45 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,67 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
diff-lcs (1.1.2) | ||
addressable (2.3.5) | ||
builder (3.2.2) | ||
diff-lcs (1.2.4) | ||
faraday (0.8.8) | ||
multipart-post (~> 1.2.0) | ||
git (1.2.5) | ||
jeweler (1.5.2) | ||
bundler (~> 1.0.0) | ||
github_api (0.10.1) | ||
addressable | ||
faraday (~> 0.8.1) | ||
hashie (>= 1.2) | ||
multi_json (~> 1.4) | ||
nokogiri (~> 1.5.2) | ||
oauth2 | ||
hashie (2.0.5) | ||
highline (1.6.19) | ||
httpauth (0.2.0) | ||
jeweler (1.8.6) | ||
builder | ||
bundler (~> 1.0) | ||
git (>= 1.2.5) | ||
github_api (= 0.10.1) | ||
highline (>= 1.6.15) | ||
nokogiri (= 1.5.10) | ||
rake | ||
rake (0.9.0) | ||
rcov (0.9.9) | ||
rspec (2.4.0) | ||
rspec-core (~> 2.4.0) | ||
rspec-expectations (~> 2.4.0) | ||
rspec-mocks (~> 2.4.0) | ||
rspec-core (2.4.0) | ||
rspec-expectations (2.4.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.4.0) | ||
rdoc | ||
json (1.8.0) | ||
jwt (0.1.8) | ||
multi_json (>= 1.5) | ||
multi_json (1.7.8) | ||
multi_xml (0.5.5) | ||
multipart-post (1.2.0) | ||
nokogiri (1.5.10) | ||
oauth2 (0.9.2) | ||
faraday (~> 0.8) | ||
httpauth (~> 0.2) | ||
jwt (~> 0.1.4) | ||
multi_json (~> 1.0) | ||
multi_xml (~> 0.5) | ||
rack (~> 1.2) | ||
rack (1.5.2) | ||
rake (10.1.0) | ||
rdoc (4.0.1) | ||
json (~> 1.4) | ||
rspec (2.14.1) | ||
rspec-core (~> 2.14.0) | ||
rspec-expectations (~> 2.14.0) | ||
rspec-mocks (~> 2.14.0) | ||
rspec-core (2.14.4) | ||
rspec-expectations (2.14.0) | ||
diff-lcs (>= 1.1.3, < 2.0) | ||
rspec-mocks (2.14.2) | ||
simplecov (0.7.1) | ||
multi_json (~> 1.0) | ||
simplecov-html (~> 0.7.1) | ||
simplecov-html (0.7.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler (~> 1.0.0) | ||
jeweler (~> 1.5.2) | ||
rcov | ||
rspec (>= 2.3.0) | ||
bundler (~> 1.3.0) | ||
jeweler (~> 1.8.6) | ||
rspec (~> 2.14.0) | ||
simplecov (~> 0.7.1) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,46 @@ | ||
module Haversine | ||
class Distance | ||
include Comparable | ||
|
||
GREAT_CIRCLE_RADIUS_MILES = 3956 | ||
GREAT_CIRCLE_RADIUS_KILOMETERS = 6371 # some algorithms use 6367 | ||
GREAT_CIRCLE_RADIUS_FEET = GREAT_CIRCLE_RADIUS_MILES * 5280 | ||
GREAT_CIRCLE_RADIUS_METERS = GREAT_CIRCLE_RADIUS_KILOMETERS * 1000 | ||
GREAT_CIRCLE_RADIUS_NAUTICAL_MILES = GREAT_CIRCLE_RADIUS_MILES / 1.15078 | ||
|
||
attr_reader :great_circle_distance | ||
|
||
def initialize(great_circle_distance) | ||
@great_circle_distance = great_circle_distance | ||
end | ||
|
||
def to_miles | ||
@great_circle_distance * GREAT_CIRCLE_RADIUS_MILES | ||
end | ||
alias_method :to_mi, :to_miles | ||
|
||
def to_kilometers | ||
@great_circle_distance * GREAT_CIRCLE_RADIUS_KILOMETERS | ||
end | ||
alias_method :to_km, :to_kilometers | ||
|
||
def to_meters | ||
@great_circle_distance * GREAT_CIRCLE_RADIUS_METERS | ||
end | ||
alias_method :to_m, :to_meters | ||
|
||
def to_feet | ||
@great_circle_distance * GREAT_CIRCLE_RADIUS_FEET | ||
end | ||
alias_method :to_ft, :to_feet | ||
|
||
|
||
def to_nautical_miles | ||
@great_circle_distance * GREAT_CIRCLE_RADIUS_NAUTICAL_MILES | ||
end | ||
alias_method :to_nm, :to_nautical_miles | ||
|
||
def <=>(other) | ||
great_circle_distance <=> other.great_circle_distance | ||
end | ||
end | ||
end | ||
end |
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
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