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


21
22
23
# File 'lib/montrose/rule/nth_day_of_year.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_year.rb', line 13

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

.apply_options?(opts) ⇒ Boolean


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

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

Instance Method Details

#include?(time) ⇒ Boolean


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

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