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



20
21
22
# File 'lib/montrose/rule/nth_day_of_year.rb', line 20

def initialize(days)
  @days = days
end

Class Method Details

.apply_options(opts) ⇒ Object



12
13
14
# File 'lib/montrose/rule/nth_day_of_year.rb', line 12

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

.apply_options?(opts) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/montrose/rule/nth_day_of_year.rb', line 8

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

Instance Method Details

#include?(time) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/montrose/rule/nth_day_of_year.rb', line 24

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