Class: Montrose::Clock

Inherits:
Object
  • Object
show all
Defined in:
lib/montrose/clock.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Clock

Returns a new instance of Clock.



7
8
9
10
11
12
13
14
# File 'lib/montrose/clock.rb', line 7

def initialize(opts = {})
  @options = Montrose::Options.merge(opts)
  @time = nil
  @every = @options.fetch(:every) { fail ConfigurationError, "Required option :every not provided" }
  @interval = @options.fetch(:interval)
  @start_time = @options.fetch(:start_time)
  @at = @options.fetch(:at, []).sort
end

Instance Method Details

#peekObject



23
24
25
# File 'lib/montrose/clock.rb', line 23

def peek
  next_time(false)
end

#tickObject

Advances time to new unit by increment and sets new time as “current” time for next tick



19
20
21
# File 'lib/montrose/clock.rb', line 19

def tick
  @time = next_time(true)
end