class Montrose::Rule::DayOfMonth
Public Class Methods
Source
# File lib/montrose/rule/day_of_month.rb, line 8 def self.apply_options(opts) opts[:mday] end
Source
# File lib/montrose/rule/day_of_month.rb, line 16 def initialize(days) @days = days end
Initializes rule
@param [Array<Fixnum>] days - valid days of month, i.e. [1, 2, -1]
Public Instance Methods
Source
# File lib/montrose/rule/day_of_month.rb, line 20 def include?(time) @days.include?(time.mday) || included_from_end_of_month?(time) end
Private Instance Methods
Source
# File lib/montrose/rule/day_of_month.rb, line 27 def included_from_end_of_month?(time) month_days = ::Montrose::Utils.days_in_month(time.month, time.year) # given by activesupport @days.any? { |d| month_days + d + 1 == time.mday } end
matches days specified at negative numbers