Class: EmmyHttp::Timer
- Inherits:
-
Object
- Object
- EmmyHttp::Timer
- Defined in:
- lib/emmy_http/timer.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
Instance Method Summary collapse
- #await ⇒ Object
-
#initialize(interval) ⇒ Timer
constructor
A new instance of Timer.
- #start ⇒ Object
Constructor Details
#initialize(interval) ⇒ Timer
Returns a new instance of Timer.
8 9 10 |
# File 'lib/emmy_http/timer.rb', line 8 def initialize(interval) @interval = interval end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
4 5 6 |
# File 'lib/emmy_http/timer.rb', line 4 def interval @interval end |
Instance Method Details
#await ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/emmy_http/timer.rb', line 18 def await Fiber.await do |fiber| # create connection start on :timeout do fiber.resume true end end end |
#start ⇒ Object
12 13 14 15 16 |
# File 'lib/emmy_http/timer.rb', line 12 def start EmmyMachine.timeout(interval) do timeout! end end |