Class: Montrose::Rule::NthDayOfMonth

Inherits:
Object
  • Object
show all
Includes:
Montrose::Rule
Defined in:
lib/montrose/rule/nth_day_of_month.rb

Defined Under Namespace

Classes: MonthDay

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Montrose::Rule

#advance!, #continue?, included

Constructor Details

#initialize(days) ⇒ NthDayOfMonth

Initializes rule

Parameters:

  • days (Hash)
    • valid days of week to month occurrence pairs


21
22
23
# File 'lib/montrose/rule/nth_day_of_month.rb', line 21

def initialize(days)
  @days = days
end

Class Method Details

.apply_options(opts) ⇒ Object


13
14
15
# File 'lib/montrose/rule/nth_day_of_month.rb', line 13

def self.apply_options(opts)
  opts[:day]
end

.apply_options?(opts) ⇒ Boolean

Returns:

  • (Boolean)

9
10
11
# File 'lib/montrose/rule/nth_day_of_month.rb', line 9

def self.apply_options?(opts)
  opts[:every] == :month && opts[:day].is_a?(Hash)
end

Instance Method Details

#include?(time) ⇒ Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/montrose/rule/nth_day_of_month.rb', line 25

def include?(time)
  @days.key?(time.wday) && nth_day?(time)
end