class Mhc::DateEnumerator::Weekly

Enumerate weekly dates like: Tue

Public Class Methods

new(start_date:, end_date:, interval: 1, wkst: 1, wday:) click to toggle source
Calls superclass method Mhc::DateEnumerator::Base::new
# File lib/mhc/date_enumerator.rb, line 210
def initialize(start_date:, end_date:, interval: 1, wkst: 1, wday:)
  super(start_date: start_date, end_date: end_date, interval: interval)
  @wday = wday
end

Private Instance Methods

frame_manager() click to toggle source
# File lib/mhc/date_enumerator.rb, line 217
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/mhc/date_enumerator.rb, line 223
def occurrence_in_frame(date)
  bof = date - ((date.wday - @wkst) % 7)
  candidate = bof + (@wday - bof.wday) % 7
  return candidate if date <= candidate
  return nil
end