Class: Timer::Timeout

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

Instance Attribute Summary

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) ⇒ Timeout

Returns a new instance of Timeout.



74
75
76
77
# File 'lib/skype/os/timer.rb', line 74

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

Class Method Details

.polling(now) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/skype/os/timer.rb', line 61

def polling now
  @stack.delete_if do |timeout|
    if now >= timeout.term
      timeout.block.call
      true
    else
      false
    end
  end
end