Sha256: 7a1b0217c70424d1bd680cb42c47d3a68785fda8a0520e89e82ec97c84979aa2
Contents?: true
Size: 558 Bytes
Versions: 2
Compression:
Stored size: 558 Bytes
Contents
module Rasti module Web class Stream TIMEOUT = 0.0001 def initialize @queue = Queue.new @closed = false end def write(message) raise 'Closed stream' if closed? @queue << message end def each while open? message = @queue.pop yield message if message sleep TIMEOUT end end def close @closed = true end def closed? @closed end def open? !closed? end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rasti-web-0.2.3 | lib/rasti/web/stream.rb |
rasti-web-0.2.2 | lib/rasti/web/stream.rb |