class Cyclical::YeardaysFilter

Attributes

yeardays[R]

Public Class Methods

new(*yeardays) click to toggle source
# File lib/cyclical/filters/yeardays_filter.rb, line 6
def initialize(*yeardays)
  raise ArgumentError, "Specify at least one day of the month" if yeardays.empty?

  @yeardays = yeardays.sort
end

Public Instance Methods

match?(date) click to toggle source
# File lib/cyclical/filters/yeardays_filter.rb, line 12
def match?(date)
  last = date.end_of_year.yday
  (@yeardays.include?(date.yday) || @yeardays.include?(date.yday - last - 1))
end
next(date) click to toggle source

FIXME - traverse the days directly

# File lib/cyclical/filters/yeardays_filter.rb, line 22
def next(date)
  until match?(date)
    date += 1.day
  end

  date
end
previous(date) click to toggle source
# File lib/cyclical/filters/yeardays_filter.rb, line 30
def previous(date)
  until match?(date)
    date -= 1.day
  end

  date
end
step() click to toggle source
# File lib/cyclical/filters/yeardays_filter.rb, line 17
def step
  1.day
end