Class: Weeter::Limitator::TimeWindow

Inherits:
Object
  • Object
show all
Defined in:
lib/weeter/limitator.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TimeWindow

Returns a new instance of TimeWindow.



18
19
20
21
# File 'lib/weeter/limitator.rb', line 18

def initialize(options = {})
  @start = options.fetch(:start)
  @duration = options.fetch(:duration)
end

Instance Method Details

#begin_new_window(at) ⇒ Object



27
28
29
# File 'lib/weeter/limitator.rb', line 27

def begin_new_window(at)
  @start = at
end

#over?(time) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/weeter/limitator.rb', line 23

def over?(time)
  time - @start > @duration
end