Class: EventMachine::PeriodicTimer
- Inherits:
-
Object
- Object
- EventMachine::PeriodicTimer
- Defined in:
- lib/eventmachine.rb
Overview
TODO, document this
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
Instance Method Summary collapse
- #cancel ⇒ Object
- #fire ⇒ Object
-
#initialize(*args, &block) ⇒ PeriodicTimer
constructor
A new instance of PeriodicTimer.
- #schedule ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ PeriodicTimer
Returns a new instance of PeriodicTimer.
1861 1862 1863 1864 1865 |
# File 'lib/eventmachine.rb', line 1861 def initialize *args, &block @interval = args.shift @code = args.shift || block schedule end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
1860 1861 1862 |
# File 'lib/eventmachine.rb', line 1860 def interval @interval end |
Instance Method Details
#cancel ⇒ Object
1875 1876 1877 |
# File 'lib/eventmachine.rb', line 1875 def cancel @cancelled = true end |
#fire ⇒ Object
1869 1870 1871 1872 1873 1874 |
# File 'lib/eventmachine.rb', line 1869 def fire unless @cancelled @code.call schedule end end |
#schedule ⇒ Object
1866 1867 1868 |
# File 'lib/eventmachine.rb', line 1866 def schedule EventMachine::add_timer @interval, proc {self.fire} end |