time_frame 0.4.2 → 0.4.3

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: 00c76a3400b8cad304f5c52c6b8d619f69dfd222
4
- data.tar.gz: 0f77d91410ec48f03bf77a4522b53d6cad56caee
3
+ metadata.gz: 16119ae2815aedbad4ad320c8e31c4bf7c1d9389
4
+ data.tar.gz: 93f06cafdda61db5d3ab2b68ce126307c1f9bbf9
5
5
  SHA512:
6
- metadata.gz: 452f866f8489f4c3611265981fe38c516e6f54f6d377476d7e34f927dc72121d74d824f0ebcebc09cbc51437c82d57a5793a902b61389295c603dee7c349ffd6
7
- data.tar.gz: ea33d048127eea7b77e5470b0057ac0739cfe0e5a2955b9f16e9e0ddb515ba698eecf184b7d3d27b65d2d106b1149d5621e0f4755522457fae4fd7a026ee5520
6
+ metadata.gz: 124139bd01a35c6e7e9ae9ca22aa4c042bcc0b3df0880ba2814bfe57eef074a55766515bd31ca2e4b5bc660a60400ac2e35af492bab8347e7b5efe589f7f4b1f
7
+ data.tar.gz: 906d7abb6482845a0fd455e43520cbf79b6b8951ab12e7590f8b8bdb91cb960403fc90ec94181afa326245447170ec9dea5dad29e709ff55f963bd443b313bf4
@@ -27,6 +27,12 @@ class TimeFrame
27
27
  max == other.max
28
28
  end
29
29
 
30
+ alias_method :eql?, :==
31
+
32
+ def hash
33
+ [min, max].hash
34
+ end
35
+
30
36
  def cover?(element)
31
37
  if rangy?(element)
32
38
  element.empty? || min <= element.min && element.max <= max
@@ -1,5 +1,5 @@
1
1
  # Encoding: utf-8
2
2
  # gem version
3
3
  class TimeFrame
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.3'
5
5
  end
@@ -10,6 +10,18 @@ describe TimeFrame do
10
10
  I18n.enforce_available_locales = true
11
11
  end
12
12
 
13
+ it "should be hashable" do
14
+ hash = {}
15
+ time_frame1 = TimeFrame.new(min: time, duration: duration)
16
+ time_frame2 = TimeFrame.new(min: time, duration: duration)
17
+ time_frame3 = TimeFrame.new(min: time, duration: duration / 2)
18
+ time_frame4 = TimeFrame.new(min: time - duration / 2 , max: time + duration)
19
+ hash[time_frame1] = 1
20
+ expect(hash[time_frame2]).to eq 1
21
+ expect(hash[time_frame3]).not_to eq 1
22
+ expect(hash[time_frame4]).not_to eq 1
23
+ end
24
+
13
25
  describe '#min and #max' do
14
26
  context 'when given two times' do
15
27
  context 'and min is smaller than max' 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.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Derichs