Class: Repeatable::Expression::DayInMonth

Inherits:
Date
  • Object
show all
Includes:
LastDateOfMonth
Defined in:
lib/repeatable/expression/day_in_month.rb

Instance Method Summary collapse

Methods included from LastDateOfMonth

#last_date_of_month

Methods inherited from Date

#==, #hash

Methods inherited from Base

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

Constructor Details

#initialize(day:) ⇒ void

Parameters:

  • day (Integer)


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

def initialize(day:)
  @day = day
end

Instance Method Details

#include?(date) ⇒ Boolean

Parameters:

  • date (::Date)

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/repeatable/expression/day_in_month.rb', line 14

def include?(date)
  if day < 0
    date - last_date_of_month(date) - 1 == day
  else
    date.day == day
  end
end