geospatial 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/geospatial/distance.rb +6 -0
- data/lib/geospatial/version.rb +1 -1
- data/spec/geospatial/distance_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f680a683a9711ab54aa842e366d8bcf331201221
|
4
|
+
data.tar.gz: c9a05d601b5e06486bdcf5a387ebcdeb3c771ec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb91f9ce99d727800906b8781b378753b508c16b54bac52f4fd6bcd0b51fd1a1467728d82b20ca18c2905e2c36fba31b10975512dde2dc60dd8f24f2350a904
|
7
|
+
data.tar.gz: fb3e122187a2d047485253e90db1e19acd6b0d2667f331fd17326034c98f2483c01b6fe6c5e9929f9e0839d67c89c483b38095a5570d6fcf3ded6485b39945bc
|
data/lib/geospatial/distance.rb
CHANGED
@@ -21,6 +21,8 @@
|
|
21
21
|
module Geospatial
|
22
22
|
# This location is specifically relating to a WGS84 coordinate on Earth.
|
23
23
|
class Distance
|
24
|
+
include Comparable
|
25
|
+
|
24
26
|
# Distance in meters:
|
25
27
|
def initialize(value)
|
26
28
|
@value = value
|
@@ -76,5 +78,9 @@ module Geospatial
|
|
76
78
|
def == other
|
77
79
|
@value == other.to_f
|
78
80
|
end
|
81
|
+
|
82
|
+
def <=> other
|
83
|
+
@value <=> other.to_f
|
84
|
+
end
|
79
85
|
end
|
80
86
|
end
|
data/lib/geospatial/version.rb
CHANGED
@@ -44,4 +44,9 @@ RSpec.describe Geospatial::Distance.new(10000) do
|
|
44
44
|
it "can subtract distances" do
|
45
45
|
expect(subject - 100).to be == 9900.0
|
46
46
|
end
|
47
|
+
|
48
|
+
it "can sort distances" do
|
49
|
+
expect([subject, subject*2, subject*3].min).to be == subject
|
50
|
+
expect([subject, subject*2, subject*3].max).to be == (subject*3)
|
51
|
+
end
|
47
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geospatial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|