Class: Montrose::Rule::During

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

Defined Under Namespace

Classes: TimeOfDayRange

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Montrose::Rule

#advance!, #continue?, included

Constructor Details

#initialize(during) ⇒ During

Initializes rule

Parameters:

  • during (Array<Array<Fixnum>>)

    array of time parts arrays, e.g. [[9, 0, 0], [17, 0, 0]], i.e., “9 to 5”



16
17
18
# File 'lib/montrose/rule/during.rb', line 16

def initialize(during)
  @during = during.map { |first, last| TimeOfDayRange.new(first, last) }
end

Class Method Details

.apply_options(opts) ⇒ Object



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

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

Instance Method Details

#include?(time) ⇒ Boolean

Returns:

  • (Boolean)


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

def include?(time)
  @during.any? { |range| range.include?(time) }
end