fat_period 1.1.1 → 1.2.0

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
  SHA256:
3
- metadata.gz: 05402b5173907362901a6890276937450921c418596ebe53e7d3576bcebd3d7b
4
- data.tar.gz: 4d78c11cb533cb6f45f8e6cd941887c8cc2f1645c4db5052ad543627228c3e73
3
+ metadata.gz: 7a36af9ab31a0faffb0b9128748deb78fa97b8cb56581bcf3b47b8a2a8776d29
4
+ data.tar.gz: '089e00bbce43fe66642ef419c9824fab84ab3a6b36aecc586aeb383662c10aa2'
5
5
  SHA512:
6
- metadata.gz: 5fcb751568bcf4c7f33ee03f4a60c55bbbf04def94475069383ed31400fc62dc8c46d70affa60374b0cace8016b1f60655275127a6cbbed36479f7cc86972879
7
- data.tar.gz: 8b5120f531483283c834531b7b3a8ddfbc0e7f816087cbcaa50338c74a06990aa6bce5d619ac0331976e05608b645406d6ca6723a3cfec8bc936f2584a4ccc40
6
+ metadata.gz: 83ebcd8b723bd5f95845acf7ecd831293f88ccd15b31caec79d23e1e4bf308d49b02c43556ff85eaebbe9b31d28c683c5cb5dec1418ebfa2f2758790206d731c
7
+ data.tar.gz: 7e19c54d5e179b20ff715e28b2ae191ada78ee75553832b07b48b3bba82ea617494208de44ae18900f45258ffb0de7be60fd5beadf200a7182921f690aebd9a7
@@ -29,8 +29,9 @@ class Period
29
29
  # @raise [ArgumentError] if first date is later than last date
30
30
  # @return [Period]
31
31
  def initialize(first, last)
32
- @first = Date.ensure_date(first)
33
- @last = Date.ensure_date(last)
32
+ @first = Date.ensure_date(first).freeze
33
+ @last = Date.ensure_date(last).freeze
34
+ freeze
34
35
 
35
36
  return unless @first > @last
36
37
 
@@ -180,6 +181,20 @@ class Period
180
181
  !(self == other)
181
182
  end
182
183
 
184
+ # Return the hash value for this Period. Make Period's with identical
185
+ # values test eql? so that they may be used as hash keys.
186
+ #
187
+ # @return [Integer]
188
+ def hash
189
+ (first.hash | last.hash)
190
+ end
191
+
192
+ def eql?(other)
193
+ return nil unless other.is_a?(Period)
194
+
195
+ hash == other.hash
196
+ end
197
+
183
198
  # Return whether this Period contains the given date.
184
199
  #
185
200
  # @param date [Date] date to test
@@ -1,3 +1,3 @@
1
1
  module FatPeriod
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_period
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-07 00:00:00.000000000 Z
11
+ date: 2020-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler