Class: Whoosh::Streaming::QueueWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/whoosh/streaming/stream_body.rb

Instance Method Summary collapse

Constructor Details

#initialize(queue) ⇒ QueueWriter

Returns a new instance of QueueWriter.



9
10
11
12
# File 'lib/whoosh/streaming/stream_body.rb', line 9

def initialize(queue)
  @queue = queue
  @closed = false
end

Instance Method Details

#closeObject



23
24
25
# File 'lib/whoosh/streaming/stream_body.rb', line 23

def close
  @closed = true
end

#closed?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/whoosh/streaming/stream_body.rb', line 27

def closed?
  @closed
end

#flushObject



19
20
21
# File 'lib/whoosh/streaming/stream_body.rb', line 19

def flush
  # no-op — queue delivers immediately
end

#write(data) ⇒ Object



14
15
16
17
# File 'lib/whoosh/streaming/stream_body.rb', line 14

def write(data)
  return if @closed
  @queue.push(data)
end