opium 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07aca24af6b9ba852256c1c3c7af22edb123b079
4
- data.tar.gz: e74fb2a45195da1987a2a10e2d8aeb41672e027d
3
+ metadata.gz: 6a18b9e563fc79c5c86b05f3eb423e6b6eed3f52
4
+ data.tar.gz: c411e0433a02b598dd1f8dc7348f70ad1a5eda8b
5
5
  SHA512:
6
- metadata.gz: ef07d8f75c9b1dbc346258477854c7a5c14ce63e69ec26baa05f55eba4564dbef2d5c07d42d9bc58727d116b540422414943b7264280c072c8d67d1c3f049e84
7
- data.tar.gz: dcbea8a0e2b70fe38018fd4fb060a56ed13c4847e26f41e99cda85df4a50e6e16ff7beb3eb25f926b1db6526c00ddd16127c3f0a90f6774e828ec75f3f2e7c29
6
+ metadata.gz: 4d4e338a6aa6d2f58dfa7b549c0ce656ee1d07f08f4b1dbd33f54c1ec48d716dacdac2a78373850301a9480312d149c0889868a933e850b200306d84da9bdbd6
7
+ data.tar.gz: 9133125cb88dca90ed7f86e3c092876e50dca84ce4f430a733e4048f4774e3f3f79f073062c65aa65af9b562425583a6103dd2a4f770623a76b33bdda8512ae8
@@ -1,3 +1,7 @@
1
+ ## 1.3.4
2
+ ### New Features
3
+ - Opium::GeoPoint now provides a custom === operator; this either delegates to == (if given another geo point), to != (if given GeoPoint; NULL_ISLAND is an invalid location!), or nil if anything else.
4
+
1
5
  ## 1.3.3
2
6
  ### New Features
3
7
  - Opium::GeoPoint now implements Comparable
@@ -31,9 +31,20 @@ module Opium
31
31
  end
32
32
 
33
33
  def <=>( geo_point )
34
+ return nil unless geo_point.is_a?( self.class )
34
35
  [self.latitude, self.longitude] <=> [geo_point.latitude, geo_point.longitude]
35
36
  end
36
37
 
38
+ def ===( other )
39
+ if other.is_a? self.class
40
+ self == other
41
+ elsif other <= self.class
42
+ self != NULL_ISLAND
43
+ else
44
+ nil
45
+ end
46
+ end
47
+
37
48
  NULL_ISLAND = new( [0, 0] ).freeze
38
49
 
39
50
  class << self
@@ -1,3 +1,3 @@
1
1
  module Opium
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.4"
3
3
  end
@@ -101,6 +101,37 @@ describe Opium::GeoPoint do
101
101
  end
102
102
  end
103
103
 
104
+ describe '.===' do
105
+ let(:result) { a === described_class }
106
+
107
+ context 'with a real location' do
108
+ let(:a) { described_class.new( [1, 1] ) }
109
+
110
+ it { expect( result ).to eq true }
111
+ end
112
+
113
+ context 'with NULL_ISLAND' do
114
+ let(:a) { described_class::NULL_ISLAND }
115
+
116
+ it { expect( result ).to eq false }
117
+ end
118
+
119
+ context 'when compared against an actual location' do
120
+ let(:result) { a === b }
121
+ let(:a) { described_class.new( [1, 1] ) }
122
+ let(:b) { described_class.new( [1, 1] ) }
123
+
124
+ it { expect( result ).to eq true }
125
+ end
126
+
127
+ context 'when compared against non geo data' do
128
+ let(:result) { a === Integer }
129
+ let(:a) { described_class.new( [1, 1] ) }
130
+
131
+ it { expect( result ).to be_falsy }
132
+ end
133
+ end
134
+
104
135
  describe "instance" do
105
136
  describe "with an array value" do
106
137
  subject { described_class.new [33.33, -117.117] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Bowers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler