Sha256: 7993487d7dafc5931e563ae6a1d6c6668a233db9c62dfb855a1d8c10aa04503b
Contents?: true
Size: 714 Bytes
Versions: 11
Compression:
Stored size: 714 Bytes
Contents
require "forwardable" module Montrose module Rule class NthDayMatcher extend Forwardable def_delegators :@period_day, :nth_day, :first_wday, :total_days def initialize(wday, period_day) @wday = wday @period_day = period_day end def matches?(nth_occ) nth_occ == current_occ || (nth_occ < 0 && (total_occ + nth_occ + 1) == current_occ) end private def current_occ @current_occ ||= (nth_day - first_occ) / 7 + 1 end def total_occ @total_occ ||= ((total_days - first_occ + 1) / 7.0).ceil end def first_occ @first_occ ||= ((7 - first_wday) + @wday) % 7 + 1 end end end end
Version data entries
11 entries across 11 versions & 1 rubygems