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 +4 -4
- data/lib/time_frame/time_frame.rb +6 -2
- data/lib/time_frame/version.rb +1 -1
- data/spec/time_frame_spec.rb +20 -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: 386f6c3ac3264d001e0178fd259596f891155635
|
4
|
+
data.tar.gz: 4446b493f555ccd977042920a76044efc1ecdf8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
63
|
+
item.max_float < min_float
|
60
64
|
else
|
61
65
|
item.to_f < min_float
|
62
66
|
end
|
data/lib/time_frame/version.rb
CHANGED
data/spec/time_frame_spec.rb
CHANGED
@@ -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.
|
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-
|
13
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|