Class: Montrose::Rule::NthDayOfYear

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

Defined Under Namespace

Classes: YearDay

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Montrose::Rule

#advance!, #continue?, included

Constructor Details

#initialize(days) ⇒ NthDayOfYear

Initializes rule

Parameters:

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



22
23
24
# File 'lib/montrose/rule/nth_day_of_year.rb', line 22

def initialize(days)
  @days = days
end

Class Method Details

.apply_options(opts) ⇒ Object



14
15
16
# File 'lib/montrose/rule/nth_day_of_year.rb', line 14

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

.apply_options?(opts) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/montrose/rule/nth_day_of_year.rb', line 10

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

Instance Method Details

#include?(time) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/montrose/rule/nth_day_of_year.rb', line 26

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