Class: Timer::Interval

Inherits:
Abstruct show all
Defined in:
lib/skype/os/timer.rb

Instance Attribute Summary collapse

Attributes inherited from Abstruct

#block, #term

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstruct

#delete, delete, new

Constructor Details

#initialize(term, block) ⇒ Interval

Returns a new instance of Interval.



97
98
99
100
101
# File 'lib/skype/os/timer.rb', line 97

def initialize term, block
  @term = term
  @old = Time.now.to_i
  @block = block
end

Instance Attribute Details

#oldObject

Returns the value of attribute old.



103
104
105
# File 'lib/skype/os/timer.rb', line 103

def old
  @old
end

Class Method Details

.polling(now) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/skype/os/timer.rb', line 86

def polling now
  @stack.each do |interval|
    if now >= interval.term + interval.old
      interval.old = now
      interval.block.call
    end
  end
end