time_frame 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f106979451ecad285f797d3da950839ab3f06af0
4
- data.tar.gz: b1140e0f5bc73bbcf1ec5a8dd467057f7094b57c
3
+ metadata.gz: 386f6c3ac3264d001e0178fd259596f891155635
4
+ data.tar.gz: 4446b493f555ccd977042920a76044efc1ecdf8b
5
5
  SHA512:
6
- metadata.gz: d632b2b40b133b92c70c259def3d414980ffdf548bfdbf96ed1c767ef73097df4794273268c3455076d3e358ca97641826a6b6b7efd39e04b2f0ce4c3c5d049b
7
- data.tar.gz: 088b62f79eb26489a6dfdd9d57bc39479f7cbc96e6b54f9b44012a501ef60f97246d695f52d2db7c66d9add7ee84bdb2abbd3f0ea9b20dc30af806c617f0689b
6
+ metadata.gz: fd4b735c5619dc44a5aabc730198be71ea14e00409916082af7640af37581f87b79e22aa5d985dbbb9a289eb9f5a48718bb6045d1d68e0e4809b49577f00264e
7
+ data.tar.gz: aa27285f47108fe95e0e73e161690e544f34ec5607c44b19cded583f371baaf7072a0dfd003d356a5b38e97229b72a1c22c024304302206f86fb9c0ebd41aa9b
@@ -27,6 +27,10 @@ class TimeFrame
27
27
  @max_float == other.max_float
28
28
  end
29
29
 
30
+ def <=>(other)
31
+ [@min_float, @max_float] <=> [other.min_float, other.max_float]
32
+ end
33
+
30
34
  alias_method :eql?, :==
31
35
 
32
36
  def hash
@@ -46,7 +50,7 @@ class TimeFrame
46
50
  case
47
51
  when item.is_a?(TimeFrame)
48
52
  fail_if_empty item
49
- item.min.to_f > max_float
53
+ item.min_float > max_float
50
54
  else
51
55
  item.to_f > max_float
52
56
  end
@@ -56,7 +60,7 @@ class TimeFrame
56
60
  case
57
61
  when item.is_a?(TimeFrame)
58
62
  fail_if_empty item
59
- item.max.to_f < min_float
63
+ item.max_float < min_float
60
64
  else
61
65
  item.to_f < min_float
62
66
  end
@@ -1,5 +1,5 @@
1
1
  # Encoding: utf-8
2
2
  # gem version
3
3
  class TimeFrame
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
@@ -189,6 +189,26 @@ describe TimeFrame do
189
189
  end
190
190
  end
191
191
 
192
+ describe '#<=>' do
193
+ let(:time_frames) do
194
+ array = TimeFrame.new(min: Time.utc(2014), duration: 30.days)
195
+ .split_by_interval(1.day)
196
+ time_frame1 = TimeFrame.new(min: Time.utc(2014), duration: 2.days)
197
+ array << time_frame1
198
+ array << time_frame1.shift_by(1.day)
199
+ array << time_frame1.shift_by(2.day)
200
+ array
201
+ end
202
+ it 'sorts correctly' do
203
+ to_be_sorted = time_frames.shuffle
204
+ to_be_sorted.sort!
205
+ to_be_sorted.each_cons(2) do |time_frame1, time_frame2|
206
+ expect(time_frame1.min <= time_frame2.min).to be_truthy
207
+ expect(time_frame1.max <= time_frame2.max).to be_truthy
208
+ end
209
+ end
210
+ end
211
+
192
212
  describe '#cover?' do
193
213
  let(:time_frame) { TimeFrame.new(min: time, duration: 4.hours) }
194
214
  context 'when argument is a Time instance' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_frame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Derichs
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-10-29 00:00:00.000000000 Z
13
+ date: 2014-10-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake