class ThomasUtils::ObjectStream
Public Class Methods
new(&callback)
click to toggle source
# File lib/thomas_utils/object_stream.rb, line 4 def initialize(&callback) @buffer = Queue.new @callback = callback end
Public Instance Methods
<<(item)
click to toggle source
# File lib/thomas_utils/object_stream.rb, line 9 def <<(item) @buffer << item end
flush()
click to toggle source
# File lib/thomas_utils/object_stream.rb, line 13 def flush length = @buffer.size items = length.times.map { @buffer.pop } @callback.call(items) end