Class: Montrose::Rule::Until

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Montrose::Rule

#advance!, included

Constructor Details

#initialize(opts) ⇒ Until

Returns a new instance of Until.



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

def initialize(opts)
  @end_time = opts.fetch(:until)
  @exclude_end = opts.fetch(:exclude_end)
end

Class Method Details

.apply_options(opts) ⇒ Object



8
9
10
11
12
# File 'lib/montrose/rule/until.rb', line 8

def self.apply_options(opts)
  return false unless opts[:until]

  {until: opts[:until], exclude_end: opts.fetch(:exclude_end, false)}
end

Instance Method Details

#continue?(_time) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/montrose/rule/until.rb', line 27

def continue?(_time)
  false
end

#include?(time) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/montrose/rule/until.rb', line 19

def include?(time)
  if @exclude_end
    time < @end_time
  else
    time <= @end_time
  end
end