periodoxical 0.7.2 → 0.8.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
  SHA256:
3
- metadata.gz: 01bdfec5ba5930f743cc1c4197e0964631c8dde5be1bb14c79082fe363bf72e1
4
- data.tar.gz: 6aaaf40f368acbdd78632455889298e6eb6ced8c0ee80f4ed9e96387e7d05536
3
+ metadata.gz: 78125f7c8e33a8588c933d7b0438daa5d0913394fe9c141e752dd73fc1968d88
4
+ data.tar.gz: 60acbba0684d36991ac7bffcb21dc8a97e27bfb313d1ab9641668463e73c718c
5
5
  SHA512:
6
- metadata.gz: dc697912db1f3a5439ffd3cdf3371c4be7f4475bb2bbae1f01c2ac42887d6041c45763e1977eabf8f68e5f6ee7c7c0d728e80153796acd419d9741a7a3126d5f
7
- data.tar.gz: 7a0c713a31ccca86c48b08bdcf1908056475a589c7adc0b93ed94dd13af0ebd35fe58151340fe2e88ff3da13d653673064c9c1d3500e9dbe61845528ecdbb207
6
+ metadata.gz: df7a8cc7abe1139af195aebe455feb7c66b75e27e3a8d43e4c862ec362111756a461b7293efe3c3fdcca50eb1f70d5fdb5de04e740014a4fc33fe3f324e8d6ec
7
+ data.tar.gz: '070876a087c2712b12f497054966f9cd98ac3d0e3eab1e4337e165e2ea42cef5ea4dd5b43b714393d92d14ddab2119b426128cf9d85f5de845b9e32959f72b1d'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- periodoxical (0.6.2)
4
+ periodoxical (0.8.3)
5
5
  tzinfo (~> 2.0, >= 2.0.0)
6
6
  week_of_month (= 1.2.6)
7
7
 
data/README.md CHANGED
@@ -186,7 +186,7 @@ Periodoxical.generate(
186
186
 
187
187
  ### Example 5 - when specifying time blocks using day-of-month and/or week-of-month and/or month.
188
188
 
189
- As a Ruby dev, I want to generate the next 3 slots for **8AM - 9AM** for the **5th** and **10th** day of every month starting from **June**
189
+ As a Ruby dev, I want to generate the next 3 timeblocks for **8AM - 9AM** for the **5th** and **10th** day of every month starting from **June**
190
190
 
191
191
  ```rb
192
192
  Periodoxical.generate(
@@ -215,7 +215,7 @@ Periodoxical.generate(
215
215
  ]
216
216
  ```
217
217
 
218
- As a Ruby dev, I want to generate **4** slots for **8AM - 9AM** on **Mondays** but only in the **first two weeks** in the months of **April, May, and June**
218
+ As a Ruby dev, I want to generate **4** timeblocks for **8AM - 9AM** on **Mondays** but only in the **first two weeks** in the months of **April, May, and June**
219
219
 
220
220
  ```
221
221
  Periodoxical.generate(
@@ -251,7 +251,7 @@ Periodoxical.generate(
251
251
  ```
252
252
 
253
253
  ### Example 6 - Specify nth day-of-week in month (ie. first Monday of the Month, second Tuesday of the Month, last Friday of Month)
254
- As a Ruby dev, I want to generate slots for **8AM - 9AM** on the **first and second Mondays** and **last Fridays** of every month starting in June 2024. I can do this with the `nth_day_of_week_in_month` param.
254
+ As a Ruby dev, I want to generate timeblocks for **8AM - 9AM** on the **first and second Mondays** and **last Fridays** of every month starting in June 2024. I can do this with the `nth_day_of_week_in_month` param.
255
255
 
256
256
  ```rb
257
257
  Periodoxical.generate(
@@ -292,7 +292,7 @@ Periodoxical.generate(
292
292
  ```
293
293
 
294
294
  ### Example 7 - Exclude time blocks using the `exclusion_dates` parameter
295
- As a Ruby dev, I want to generate slots for **8AM - 9AM** on **Mondays**, except for the **Monday of June 10, 2024**.
295
+ As a Ruby dev, I want to generate timeblocks for **8AM - 9AM** on **Mondays**, except for the **Monday of June 10, 2024**.
296
296
 
297
297
  ```rb
298
298
  Periodoxical.generate(
@@ -328,6 +328,69 @@ Periodoxical.generate(
328
328
  ]
329
329
  ```
330
330
 
331
+ ### Example 8 - Every-other-nth day-of-week rules (ie. every other Tuesday, every 3rd Wednesday, every 10th Friday)
332
+
333
+ As a Ruby dev, I want to generate timeblocks for **9AM- 10AM** on **every Monday**, but **every other Tuesday**, and **every other 3rd Wednesday**. I can do this using the `days_of_week` parameter, but also using the `every` and `every_other_nth` keys to specify the every-other-nth-rules.
334
+
335
+ ```rb
336
+ Periodoxical.generate(
337
+ time_zone: 'America/Los_Angeles',
338
+ start_date: '2024-12-30',
339
+ days_of_week: {
340
+ mon: { every: true }, # every Monday (no skipping)
341
+ tue: { every_other_nth: 2 }, # every other Tuesday starting at first Tuesday from start date
342
+ wed: { every_other_nth: 3 }, # every 3rd Wednesday starting at first Wednesday from start date
343
+ },
344
+ limit: 10,
345
+ time_blocks: [
346
+ { start_time: '9:00AM', end_time: '10:00AM' },
347
+ ],
348
+ )
349
+ #=>
350
+ [
351
+ {
352
+ start: #<DateTime: 2024-12-30T09:00:00-0800>,
353
+ end: #<DateTime: 2024-12-30T10:00:00-0800>,
354
+ },
355
+ {
356
+ start: #<DateTime: 2024-12-31T09:00:00-0800>,
357
+ end: #<DateTime: 2024-12-31T10:00:00-0800>,
358
+ },
359
+ {
360
+ start: #<DateTime: 2025-01-01T09:00:00-0800>,
361
+ end: #<DateTime: 2025-01-01T10:00:00-0800>,
362
+ },
363
+ {
364
+ start: #<DateTime: 2025-01-06T09:00:00-0800>,
365
+ end: #<DateTime: 2025-01-06T10:00:00-0800>,
366
+ },
367
+ {
368
+ start: #<DateTime: 2025-01-13T09:00:00-0800>,
369
+ end: #<DateTime: 2025-01-13T10:00:00-0800>,
370
+ },
371
+ {
372
+ start: #<DateTime: 2025-01-14T09:00:00-0800>,
373
+ end: #<DateTime: 2025-01-14T10:00:00-0800>,
374
+ },
375
+ {
376
+ start: #<DateTime: 2025-01-20T09:00:00-0800>,
377
+ end: #<DateTime: 2025-01-20T10:00:00-0800>,
378
+ },
379
+ {
380
+ start: #<DateTime: 2025-01-22T09:00:00-0800>,
381
+ end: #<DateTime: 2025-01-22T10:00:00-0800>,
382
+ },
383
+ {
384
+ start: #<DateTime: 2025-01-27T09:00:00-0800>,
385
+ end: #<DateTime: 2025-01-27T10:00:00-0800>,
386
+ },
387
+ {
388
+ start: #<DateTime: 2025-01-28T09:00:00-0800>,
389
+ end: #<DateTime: 2025-01-28T10:00:00-0800>,
390
+ }
391
+ ]
392
+ ```
393
+
331
394
  ### Having Some Fun
332
395
 
333
396
  Generate all the Friday the 13ths ever since May 1980 (when the first Friday the 13th film was released).
@@ -0,0 +1,104 @@
1
+ module Periodoxical
2
+ module Validation
3
+ VALID_DAYS_OF_WEEK = %w[mon tue wed thu fri sat sun].freeze
4
+ def validate!
5
+ unless @day_of_week_time_blocks || @time_blocks
6
+ raise "`day_of_week_time_blocks` or `time_blocks` need to be provided"
7
+ end
8
+
9
+ if (@days_of_week || @days_of_week_with_alternations) && @day_of_week_time_blocks
10
+ raise "`days_of_week` and `day_of_week_time_blocks` are both provided, which leads to ambiguity. Please use only one of these parameters."
11
+ end
12
+
13
+ if @weeks_of_month
14
+ @weeks_of_month.each do |wom|
15
+ unless wom.is_a?(Integer) && wom.between?(1, 5)
16
+ raise "weeks_of_month must be an array of integers between 1 and 5"
17
+ end
18
+ end
19
+ end
20
+
21
+ # days of week are valid
22
+ if @days_of_week
23
+ @days_of_week.each do |day|
24
+ unless VALID_DAYS_OF_WEEK.include?(day.to_s)
25
+ raise "#{day} is not valid day of week format. Must be: #{VALID_DAYS_OF_WEEK}"
26
+ end
27
+ end
28
+ end
29
+
30
+ if @days_of_week_with_alternations
31
+ @days_of_week_with_alternations.each do |dow, every_other|
32
+ unless VALID_DAYS_OF_WEEK.include?(dow.to_s)
33
+ raise "#{dow} is not valid day of week format. Must be: #{VALID_DAYS_OF_WEEK}"
34
+ end
35
+ unless every_other.is_a?(Hash)
36
+ raise "days_of_week parameter is not used correctly. Please look at examples in README."
37
+ end
38
+ unless every_other[:every] || every_other[:every_other_nth]
39
+ raise "days_of_week parameter is not used correctly. Please look at examples in README."
40
+ end
41
+ if every_other[:every_other_nth]
42
+ unless every_other[:every_other_nth].is_a?(Integer)
43
+ raise "days_of_week parameter is not used correctly. Please look at examples in README."
44
+ end
45
+
46
+ unless every_other[:every_other_nth] > 1
47
+ raise "days_of_week parameter is not used correctly. Please look at examples in README."
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ if @nth_day_of_week_in_month
54
+ @nth_day_of_week_in_month.keys.each do |day|
55
+ unless VALID_DAYS_OF_WEEK.include?(day.to_s)
56
+ raise "#{day} is not valid day of week format. Must be: #{VALID_DAYS_OF_WEEK}"
57
+ end
58
+ end
59
+ @nth_day_of_week_in_month.each do |k,v|
60
+ unless v.is_a?(Array)
61
+ raise "nth_day_of_week_in_month parameter is invalid. Please look at the README for examples."
62
+ end
63
+ v.each do |num|
64
+ unless [-1,1,2,3,4,5].include?(num)
65
+ raise "nth_day_of_week_in_month parameter is invalid. Please look at the README for examples. "
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ if @nth_day_of_week_in_month && (@days_of_week || @days_of_week_with_alternations || @day_of_week_time_blocks)
72
+ raise "nth_day_of_week_in_month parameter cannot be used in combination with `days_of_week` or `day_of_week_time_blocks`. Please look at the README for examples."
73
+ end
74
+
75
+ if @day_of_week_time_blocks
76
+ @day_of_week_time_blocks.keys.each do |d|
77
+ unless VALID_DAYS_OF_WEEK.include?(d.to_s)
78
+ raise "#{d} is not a valid day of week format. Must be #{VALID_DAYS_OF_WEEK}"
79
+ end
80
+ end
81
+ end
82
+
83
+ if @days_of_month
84
+ @days_of_month.each do |dom|
85
+ unless dom.is_a?(Integer) && dom.between?(1,31)
86
+ raise 'days_of_months must be array of integers between 1 and 31'
87
+ end
88
+ end
89
+ end
90
+
91
+ if @months
92
+ @months.each do |mon|
93
+ unless mon.is_a?(Integer) && mon.between?(1, 12)
94
+ raise 'months must be array of integers between 1 and 12'
95
+ end
96
+ end
97
+ end
98
+
99
+ unless( @limit || @end_date)
100
+ raise "Either `limit` or `end_date` must be provided"
101
+ end
102
+ end
103
+ end
104
+ end
@@ -1,3 +1,3 @@
1
1
  module Periodoxical
2
- VERSION = "0.7.2"
2
+ VERSION = "0.8.3"
3
3
  end
data/lib/periodoxical.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "periodoxical/version"
2
+ require "periodoxical/validation"
2
3
  require "date"
3
4
  require "time"
4
5
  require "tzinfo"
@@ -12,7 +13,7 @@ module Periodoxical
12
13
  end
13
14
 
14
15
  class Core
15
- VALID_DAYS_OF_WEEK = %w[mon tue wed thu fri sat sun].freeze
16
+ include Periodoxical::Validation
16
17
  # @param [String] time_zone
17
18
  # Ex: 'America/Los_Angeles', 'America/Chicago',
18
19
  # TZInfo::DataTimezone#name from the tzinfo gem (https://github.com/tzinfo/tzinfo)
@@ -66,7 +67,11 @@ module Periodoxical
66
67
  )
67
68
 
68
69
  @time_zone = TZInfo::Timezone.get(time_zone)
69
- @days_of_week = days_of_week
70
+ if days_of_week.is_a?(Array)
71
+ @days_of_week = days_of_week
72
+ elsif days_of_week.is_a?(Hash)
73
+ @days_of_week_with_alternations = days_of_week
74
+ end
70
75
  @nth_day_of_week_in_month = nth_day_of_week_in_month
71
76
  @days_of_month = days_of_month
72
77
  @weeks_of_month = weeks_of_month
@@ -87,7 +92,11 @@ module Periodoxical
87
92
  # {
88
93
  # start: #<DateTime>,
89
94
  # end: #<DateTime>,
90
- # }
95
+ # },
96
+ # {
97
+ # start: #<DateTime>,
98
+ # end: #<DateTime>,
99
+ # },
91
100
  # ]
92
101
  def generate
93
102
  initialize_looping_variables!
@@ -102,87 +111,6 @@ module Periodoxical
102
111
 
103
112
  private
104
113
 
105
- def validate!
106
- unless @day_of_week_time_blocks || @time_blocks
107
- raise "`day_of_week_time_blocks` or `time_blocks` need to be provided"
108
- end
109
-
110
- if @days_of_week && @day_of_week_time_blocks
111
- raise "`days_of_week` and `day_of_week_time_blocks` are both provided, which leads to ambiguity. Please use only one of these parameters."
112
- end
113
-
114
- if @weeks_of_month
115
- @weeks_of_month.each do |wom|
116
- unless wom.is_a?(Integer) && wom.between?(1, 5)
117
- raise "weeks_of_month must be an array of integers between 1 and 5"
118
- end
119
- end
120
- end
121
-
122
- # days of week are valid
123
- if @days_of_week
124
- @days_of_week.each do |day|
125
- unless VALID_DAYS_OF_WEEK.include?(day.to_s)
126
- raise "#{day} is not valid day of week format. Must be: #{VALID_DAYS_OF_WEEK}"
127
- end
128
- end
129
- end
130
-
131
- if @nth_day_of_week_in_month
132
- @nth_day_of_week_in_month.keys.each do |day|
133
- unless VALID_DAYS_OF_WEEK.include?(day.to_s)
134
- raise "#{day} is not valid day of week format. Must be: #{VALID_DAYS_OF_WEEK}"
135
- end
136
- end
137
- @nth_day_of_week_in_month.each do |k,v|
138
- unless v.is_a?(Array)
139
- raise "nth_day_of_week_in_month parameter is invalid. Please look at the README for examples."
140
- end
141
- v.each do |num|
142
- unless [-1,1,2,3,4,5].include?(num)
143
- raise "nth_day_of_week_in_month parameter is invalid. Please look at the README for examples. "
144
- end
145
- end
146
- end
147
- end
148
-
149
- if @days_of_week && @nth_day_of_week_in_month
150
- # If both `days_of_week` and `nth_day_of_week_in_month` are provided for the same days-of-the-week, then it is ambiguous. (ie. I want this timeslot for every Monday, but also only for the first Mondays, well which one is it?)
151
- overlapping_days = @days_of_week & @nth_day_of_week_in_month.keys.map(&:to_s)
152
- unless overlapping_days.empty?
153
- raise "#{overlapping_days} is specified in both `days_of_week` and also `nth_day_of_week_in_month`, which leads to ambiguity. Pleasee look at the README for examples."
154
- end
155
- end
156
-
157
- if @day_of_week_time_blocks
158
- @day_of_week_time_blocks.keys.each do |d|
159
- unless VALID_DAYS_OF_WEEK.include?(d.to_s)
160
- raise "#{d} is not a valid day of week format. Must be #{VALID_DAYS_OF_WEEK}"
161
- end
162
- end
163
- end
164
-
165
- if @days_of_month
166
- @days_of_month.each do |dom|
167
- unless dom.is_a?(Integer) && dom.between?(1,31)
168
- raise 'days_of_months must be array of integers between 1 and 31'
169
- end
170
- end
171
- end
172
-
173
- if @months
174
- @months.each do |mon|
175
- unless mon.is_a?(Integer) && mon.between?(1, 12)
176
- raise 'months must be array of integers between 1 and 12'
177
- end
178
- end
179
- end
180
-
181
- unless( @limit || @end_date)
182
- raise "Either `limit` or `end_date` must be provided"
183
- end
184
- end
185
-
186
114
  def day_of_week_long_to_short(dow)
187
115
  {
188
116
  "Monday" => "mon",
@@ -228,8 +156,24 @@ module Periodoxical
228
156
  def initialize_looping_variables!
229
157
  @output = []
230
158
  @current_date = @start_date
159
+ @current_day_of_week = day_of_week_long_to_short(@current_date.strftime("%A"))
231
160
  @current_count = 0
232
161
  @keep_generating = true
162
+ # When there are alternations in days of week
163
+ # (ie. every other Monday, every 3rd Thursday, etc).
164
+ # We keep running tally of day_of_week counts and use modulo-math to pick out
165
+ # every n-th one.
166
+ if @days_of_week_with_alternations
167
+ @days_of_week_running_tally = {
168
+ mon: 0,
169
+ tue: 0,
170
+ wed: 0,
171
+ thu: 0,
172
+ fri: 0,
173
+ sat: 0,
174
+ sun: 0,
175
+ }
176
+ end
233
177
  end
234
178
 
235
179
  # @param [Hash] time_block
@@ -256,9 +200,19 @@ module Periodoxical
256
200
  def advance_current_date_and_check_if_reached_end_date
257
201
  @current_date = @current_date + 1
258
202
 
203
+ @current_day_of_week = day_of_week_long_to_short(@current_date.strftime("%A"))
204
+
259
205
  if @end_date && (@current_date > @end_date)
260
206
  @keep_generating = false
261
207
  end
208
+
209
+ # kill switch to stop infinite loop when `limit` is used but
210
+ # there is bug, or poorly specified rules. If @current_date goes into
211
+ # 1000 years in the future, but still no dates have been generated yet, this is
212
+ # most likely an infinite loop situation, and needs to be killed.
213
+ if @limit && ((@current_date - @start_date).to_i > 365000) && @output.empty?
214
+ raise "No end condition detected, causing infinite loop. Please check rules/conditions or raise github issue for potential bug fixed"
215
+ end
262
216
  end
263
217
 
264
218
  # @return [Boolean]
@@ -286,17 +240,36 @@ module Periodoxical
286
240
  return false unless @days_of_month.include?(@current_date.day)
287
241
  end
288
242
 
289
- # The following conditions depend on the day-of-week of current_date.
290
- day_of_week = day_of_week_long_to_short(@current_date.strftime("%A"))
291
-
292
243
  # If days of week are specified, but current_date does not satisfy it,
293
244
  # return false
294
245
  if @days_of_week
295
- return false unless @days_of_week.include?(day_of_week)
246
+ return false unless @days_of_week.include?(@current_day_of_week)
247
+ end
248
+
249
+ if @days_of_week_with_alternations
250
+ # current_date is not specified in days_of_week, so skip it
251
+ return false if @days_of_week_with_alternations[@current_day_of_week.to_sym].nil?
252
+
253
+ alternating_spec = @days_of_week_with_alternations[@current_day_of_week.to_sym]
254
+
255
+ # In the { every: true } case, we don't check the alternations logic, we just add it.
256
+ unless alternating_spec[:every]
257
+ # We are now specifying every other nth occurrence (ie. every 2nd Tuesday, every 3rd Wednesday)
258
+ alternating_frequency = alternating_spec[:every_other_nth]
259
+
260
+ unless (@days_of_week_running_tally[@current_day_of_week.to_sym] % alternating_frequency) == 0
261
+ # If day-of-week alternations are present, we need to keep track of day-of-weeks
262
+ # we have encountered and added or would have added so far.
263
+ update_days_of_week_running_tally!
264
+
265
+ return false
266
+ end
267
+ update_days_of_week_running_tally!
268
+ end
296
269
  end
297
270
 
298
271
  if @day_of_week_time_blocks
299
- dowtb = @day_of_week_time_blocks[day_of_week.to_sym]
272
+ dowtb = @day_of_week_time_blocks[@current_day_of_week.to_sym]
300
273
  return false if dowtb.nil?
301
274
  return false if dowtb.empty?
302
275
  end
@@ -304,41 +277,42 @@ module Periodoxical
304
277
  if @nth_day_of_week_in_month
305
278
  # If the day of week is specified in nth_day_of_week_in_month,
306
279
  # we need to investigate it whether or not to exclude it.
307
- if @nth_day_of_week_in_month[day_of_week.to_sym]
280
+ if @nth_day_of_week_in_month[@current_day_of_week.to_sym]
308
281
  n_occurence_of_day_of_week_in_month = ((@current_date.day - 1) / 7) + 1
309
282
  # -1 is a special case and requires extra-math
310
- if @nth_day_of_week_in_month[day_of_week.to_sym].include?(-1)
283
+ if @nth_day_of_week_in_month[@current_day_of_week.to_sym].include?(-1)
311
284
  # We basically want to convert the -1 into its 'positive-equivalent` in this month, and compare it with that.
312
285
  # For example, in June 2024, the Last Friday is also the 4th Friday. So in that case, we convert the -1 into a 4.
313
- positivized_indices = @nth_day_of_week_in_month[day_of_week.to_sym].map { |indx| positivize_index(indx, day_of_week) }
286
+ positivized_indices = @nth_day_of_week_in_month[@current_day_of_week.to_sym].map { |indx| positivize_index(indx, @current_day_of_week) }
314
287
  return positivized_indices.include?(n_occurence_of_day_of_week_in_month)
315
288
  else
316
- return @nth_day_of_week_in_month[day_of_week.to_sym].include?(n_occurence_of_day_of_week_in_month)
289
+ return @nth_day_of_week_in_month[@current_day_of_week.to_sym].include?(n_occurence_of_day_of_week_in_month)
317
290
  end
318
291
  else
319
- # if day-of-week was not specified in nth_day_of_week_in_month,
320
- # it could have been specified in either `days_of_week` or `day_of_week_time_blocks and we unfortunately need to re-check those here. I cant think of a way to further DRY-it up.
321
- return false unless @days_of_week && @day_of_week_time_blocks
322
- if @day_of_week
323
- return false unless @days_of_week.include?(day_of_week)
324
- end
325
-
326
- if @day_of_week_time_blocks
327
- dowtb = @day_of_week_time_blocks[day_of_week.to_sym]
328
- return false if dowtb.nil?
329
- return false if dowtb.empty?
330
- end
292
+ return false
331
293
  end
332
294
  end
333
295
 
334
- # Otherwise, return true
296
+ # The default return true is really only needed to support this use-case:
297
+ # Periodoxical.generate(
298
+ # time_zone: 'America/Los_Angeles',
299
+ # time_blocks: [
300
+ # {
301
+ # start_time: '9:00AM',
302
+ # end_time: '10:30AM'
303
+ # },
304
+ # ],
305
+ # start_date: '2024-05-23',
306
+ # end_date: '2024-05-27',
307
+ # )
308
+ # where if we don't specify any date-of-week/month constraints, we return all consecutive dates.
309
+ # In the future, if we don't support this case, we can use `false` as the return value.
335
310
  true
336
311
  end
337
312
 
338
313
  def add_time_blocks_from_current_date!
339
314
  if @day_of_week_time_blocks
340
- day_of_week = day_of_week_long_to_short(@current_date.strftime("%A"))
341
- time_blocks = @day_of_week_time_blocks[day_of_week.to_sym]
315
+ time_blocks = @day_of_week_time_blocks[@current_day_of_week.to_sym]
342
316
  catch :done do
343
317
  time_blocks.each do |tb|
344
318
  append_to_output_and_check_limit(tb)
@@ -372,5 +346,9 @@ module Periodoxical
372
346
 
373
347
  ((last_date.day - 1) / 7) + 1
374
348
  end
349
+
350
+ def update_days_of_week_running_tally!
351
+ @days_of_week_running_tally[@current_day_of_week.to_sym] = @days_of_week_running_tally[@current_day_of_week.to_sym] + 1
352
+ end
375
353
  end
376
354
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: periodoxical
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Li
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-02 00:00:00.000000000 Z
11
+ date: 2024-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
@@ -135,6 +135,7 @@ files:
135
135
  - bin/console
136
136
  - bin/setup
137
137
  - lib/periodoxical.rb
138
+ - lib/periodoxical/validation.rb
138
139
  - lib/periodoxical/version.rb
139
140
  - periodoxical.gemspec
140
141
  homepage: https://github.com/StevenJL/periodoxical