Class: Montrose::Clock
- Inherits:
-
Object
- Object
- Montrose::Clock
- Defined in:
- lib/montrose/clock.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Clock
constructor
A new instance of Clock.
- #peek ⇒ Object
-
#tick ⇒ Object
Advances time to new unit by increment and sets new time as “current” time for next tick.
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
#peek ⇒ Object
23 24 25 |
# File 'lib/montrose/clock.rb', line 23 def peek next_time(false) end |
#tick ⇒ Object
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 |