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.
1556 1557 1558 1559 1560 |
# File 'lib/eventmachine.rb', line 1556 def initialize *args, &block @interval = args.shift @code = args.shift || block schedule end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
1555 1556 1557 |
# File 'lib/eventmachine.rb', line 1555 def interval @interval end |
Instance Method Details
#cancel ⇒ Object
1568 1569 1570 |
# File 'lib/eventmachine.rb', line 1568 def cancel @cancelled = true end |
#fire ⇒ Object
1564 1565 1566 1567 |
# File 'lib/eventmachine.rb', line 1564 def fire @code.call schedule unless @cancelled end |
#schedule ⇒ Object
1561 1562 1563 |
# File 'lib/eventmachine.rb', line 1561 def schedule EventMachine::add_timer @interval, proc {self.fire} end |