Class: Slnky::Service::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/slnky/service/timer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTimer

Returns a new instance of Timer.



16
17
18
# File 'lib/slnky/service/timer.rb', line 16

def initialize
  @timers = []
end

Class Method Details

.instanceObject



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

#eachObject



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

#listObject



24
25
26
# File 'lib/slnky/service/timer.rb', line 24

def list
  @timers
end