fat_core 0.1.2 → 0.1.3

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: f129c833ebff73231353110dd8c50fa422eb58f3
4
- data.tar.gz: a19d2bdd83e040c1ca84553f6172ebb03e56d856
3
+ metadata.gz: cf42c04e2df2a194b2c1443f37fa544e67dc4755
4
+ data.tar.gz: 4479332da5870aad790def2b520cc0054dd66f30
5
5
  SHA512:
6
- metadata.gz: 990d55b6ab2802c6a39f372221ee0cc382e9b4bd583246c296008569982886d7ab0fd230696d18a3a829159e18c8fb2a7d41691e0c72575e780b77627be03817
7
- data.tar.gz: 6ab08c520c375249c17addca5c74039c244ac75fe53128faac21135f3f13014780de403abb165db6fa6c0c89c1f7a37e1a2012152673ca0da9aa1d2951b5728b
6
+ metadata.gz: ce1c348abc44daae141b687597ee12ce1da0415b2a7da3d5aedbf6ec83fc62f09626912296b5ff05cb188cd42e3622e03cf45c1c0d30b59da76bb0503ad1711a
7
+ data.tar.gz: 527f34537f750dbcf71764c9e2bf5c80d3f22c2f282fc76b9aac62d4e79d599ca2136a4aaeb8e484d442863a3b4ccc807ab86608c3f8fe72635f0f73cf26bc2c
@@ -47,6 +47,33 @@ class Period
47
47
  end
48
48
  end
49
49
 
50
+ # Comparable base: periods are equal only if their first and last dates are
51
+ # equal. Sorting will be by first date, then last, so periods starting on
52
+ # the same date will sort by last date, thus, from smallest to largest in
53
+ # size.
54
+ def <=>(other)
55
+ [first, last] <=> [other.first, other.last]
56
+ end
57
+
58
+ # Comparable does not include this.
59
+ def !=(other)
60
+ !(self == other)
61
+ end
62
+
63
+ # Enumerable base. Yield each day in the period.
64
+ def each
65
+ d = first
66
+ while d <= last
67
+ yield d
68
+ d = d + 1.day
69
+ end
70
+ end
71
+
72
+ # Case equality checks for inclusion of date in period.
73
+ def ===(date)
74
+ self.contains?(date)
75
+ end
76
+
50
77
  # Return a period based on two date specs (see Date.parse_spec), a '''from'
51
78
  # and a 'to' spec. If the to-spec is not given or is nil, the from-spec is
52
79
  # used for both the from- and to-spec. If no from-spec is given, return
@@ -85,14 +112,6 @@ class Period
85
112
  # TO_DATE = Period.new(Date::BOT, Date.current)
86
113
  # FOREVER = Period.new(Date::BOT, Date::EOT)
87
114
 
88
- def each
89
- d = first
90
- while d <= last
91
- yield d
92
- d = d + 1.day
93
- end
94
- end
95
-
96
115
  def self.chunk_syms
97
116
  [:day, :week, :biweek, :semimonth, :month, :bimonth,
98
117
  :quarter, :year, :irregular]
@@ -180,14 +199,6 @@ class Period
180
199
  (first..last)
181
200
  end
182
201
 
183
- def ==(other)
184
- first == other.first && last == other.last
185
- end
186
-
187
- def <=>(other)
188
- [first, size] <=> [other.first, other.size]
189
- end
190
-
191
202
  def to_s
192
203
  if first.beginning_of_year? && last.end_of_year? && first.year == last.year
193
204
  "#{first.year}"
@@ -1,7 +1,7 @@
1
1
  module FatCore
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- PATCH = 2
4
+ PATCH = 3
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty