class Montrose::Rule::DayOfYear
Public Class Methods
apply_options(opts)
click to toggle source
# File lib/montrose/rule/day_of_year.rb, line 8 def self.apply_options(opts) opts[:yday] end
new(days)
click to toggle source
Initializes rule
@param [Array<Fixnum>] days - valid days of year, e.g. [1, 2, -1]
# File lib/montrose/rule/day_of_year.rb, line 16 def initialize(days) @days = days end
Public Instance Methods
include?(time)
click to toggle source
# File lib/montrose/rule/day_of_year.rb, line 20 def include?(time) @days.include?(time.yday) || included_from_end_of_month?(time) end
Private Instance Methods
included_from_end_of_month?(time)
click to toggle source
# File lib/montrose/rule/day_of_year.rb, line 26 def included_from_end_of_month?(time) year_days = ::Montrose::Utils.days_in_year(time.year) # given by activesupport @days.any? { |d| year_days + d + 1 == time.yday } end