class EasyTimers::Timer
Wraps a timer
Attributes
callback[R]
interval[R]
name[R]
recurring[R]
time[R]
Public Class Methods
new(time, name, interval, recurring, callback)
click to toggle source
Create a new instance @param time [Float] Seconds since epoch. @param name [Symbol] A name for this timer; generated from the current clock time if nil. @param interval [Float] Seconds. @param recurring [Boolean] @param callback [Callable]
# File lib/easy_timers/timer.rb, line 15 def initialize(time, name, interval, recurring, callback) @time = time @name = name @interval = interval @recurring = recurring @callback = callback @cancelled = false if @name == nil @name = Time.now.gmtime.to_f.to_s.to_sym end end
Public Instance Methods
cancel()
click to toggle source
Cancel the timer by overwriting the callback
# File lib/easy_timers/timer.rb, line 30 def cancel() @callback = nil @cancelled = true end
cancelled?()
click to toggle source
Check if this timer has been cancelled.
# File lib/easy_timers/timer.rb, line 37 def cancelled? return @cancelled end