class Enumdate::DateEnumerator::Weekly

Enumerate weekly dates like: Tue

Public Class Methods

new(first_date:, wday:, interval: 1, wkst: 1) click to toggle source
Calls superclass method Enumdate::DateEnumerator::Base::new
# File lib/enumdate/date_enumerator.rb, line 196
def initialize(first_date:, wday:, interval: 1, wkst: 1)
  super(first_date: first_date, interval: interval, wkst: wkst)
  @wday = wday
end

Private Instance Methods

frame_manager() click to toggle source
# File lib/enumdate/date_enumerator.rb, line 203
def frame_manager
  DateFrame::Weekly
end
occurrence_in_frame(date) click to toggle source

Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue …

0   1   2   3   4   5   6   0   1   2  ...
# File lib/enumdate/date_enumerator.rb, line 209
def occurrence_in_frame(date)
  bof = date - ((date.wday - @wkst) % 7)
  candidate = bof + (@wday - bof.wday) % 7
  return candidate if date <= candidate

  nil
end