Class: EventHub::Sleeper

Inherits:
Object
  • Object
show all
Defined in:
lib/eventhub/sleeper.rb

Overview

Sleep Class which can interrupt running sleep

Instance Method Summary collapse

Instance Method Details

#start(seconds) ⇒ Object



5
6
7
8
# File 'lib/eventhub/sleeper.rb', line 5

def start(seconds)
  @reader, @writer = IO.pipe
  IO.select([@reader], nil, nil, seconds)
end

#stopObject



10
11
12
# File 'lib/eventhub/sleeper.rb', line 10

def stop
  @writer.close if @writer && !@writer.closed?
end