Class: Slnky::Service::Timer
- Inherits:
-
Object
- Object
- Slnky::Service::Timer
- Defined in:
- lib/slnky/service/timer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(seconds, method) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Timer
constructor
A new instance of Timer.
- #list ⇒ Object
Constructor Details
#initialize ⇒ Timer
Returns a new instance of Timer.
16 17 18 |
# File 'lib/slnky/service/timer.rb', line 16 def initialize @timers = [] end |
Class Method Details
.instance ⇒ Object
11 12 13 |
# File 'lib/slnky/service/timer.rb', line 11 def instance @instance ||= self.new end |
Instance Method Details
#add(seconds, method) ⇒ Object
20 21 22 |
# File 'lib/slnky/service/timer.rb', line 20 def add(seconds, method) @timers << Slnky::Service::Periodic.new(seconds, method) end |
#each ⇒ Object
28 29 30 31 32 |
# File 'lib/slnky/service/timer.rb', line 28 def each @timers.each do |t| yield t.seconds, t.method end end |
#list ⇒ Object
24 25 26 |
# File 'lib/slnky/service/timer.rb', line 24 def list @timers end |