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.
1787 1788 1789 1790 1791 |
# File 'lib/eventmachine.rb', line 1787 def initialize *args, &block @interval = args.shift @code = args.shift || block schedule end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
1786 1787 1788 |
# File 'lib/eventmachine.rb', line 1786 def interval @interval end |
Instance Method Details
#cancel ⇒ Object
1801 1802 1803 |
# File 'lib/eventmachine.rb', line 1801 def cancel @cancelled = true end |
#fire ⇒ Object
1795 1796 1797 1798 1799 1800 |
# File 'lib/eventmachine.rb', line 1795 def fire unless @cancelled @code.call schedule end end |
#schedule ⇒ Object
1792 1793 1794 |
# File 'lib/eventmachine.rb', line 1792 def schedule EventMachine::add_timer @interval, proc {self.fire} end |