Class: Repeatable::Expression::Biweekly

Inherits:
Date
  • Object
show all
Defined in:
lib/repeatable/expression/biweekly.rb

Instance Method Summary collapse

Methods inherited from Date

#==, #hash, #to_h

Methods inherited from Base

===, #difference, #intersection, #to_h, #union

Constructor Details

#initialize(weekday:, start_after: ::Date.today) ⇒ Biweekly

Returns a new instance of Biweekly.



4
5
6
7
# File 'lib/repeatable/expression/biweekly.rb', line 4

def initialize(weekday:, start_after: ::Date.today)
  @weekday = weekday
  @start_after = Date(start_after)
end

Instance Method Details

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/repeatable/expression/biweekly.rb', line 9

def include?(date)
  date >= start_after && (date - first_occurrence) % 14 == 0
end