class Montrose::Rule::NthDayOfMonth
Public Class Methods
apply_options(opts)
click to toggle source
# File lib/montrose/rule/nth_day_of_month.rb, line 12 def self.apply_options(opts) opts[:day] end
apply_options?(opts)
click to toggle source
# File lib/montrose/rule/nth_day_of_month.rb, line 8 def self.apply_options?(opts) (opts[:every] == :month || opts[:month]) && opts[:day].is_a?(Hash) end
new(days)
click to toggle source
Initializes rule
@param [Hash] days - valid days of week to month occurrence pairs
# File lib/montrose/rule/nth_day_of_month.rb, line 20 def initialize(days) @days = days end
Public Instance Methods
include?(time)
click to toggle source
# File lib/montrose/rule/nth_day_of_month.rb, line 24 def include?(time) @days.key?(time.wday) && nth_day?(time) end
Private Instance Methods
nth_day?(time)
click to toggle source
# File lib/montrose/rule/nth_day_of_month.rb, line 30 def nth_day?(time) expected_occurrences = @days[time.wday] nth_day = NthDayMatcher.new(time.wday, MonthDay.new(time)) expected_occurrences.any? { |n| nth_day.matches?(n) } end