class Grack::IOStreamer
A Rack body implementation that streams a given IO object in chunks for a Rack response.
Constants
- READ_SIZE
The number of bytes to read at a time from IO streams.
Attributes
mtime[R]
The last modified time to report for the Rack response.
Public Class Methods
new(io, mtime)
click to toggle source
Creates a new instance of this object.
@param [#read] io a readable, IO-like object. @param [Time] mtime a timestamp to use for the last modified header in the
response.
# File lib/grack/io_streamer.rb, line 16 def initialize(io, mtime) @io = io @mtime = mtime end
Public Instance Methods
each() { |chunk| ... }
click to toggle source
Iterates over the wrapped IO object in chunks, yielding each one.
@yieldparam [String] chunk a chunk read from the wrapped IO object.
# File lib/grack/io_streamer.rb, line 29 def each with_io do |io| while chunk = io.read(READ_SIZE) do yield(chunk) end end end
Private Instance Methods
with_io() { |io| ... }
click to toggle source
@yieldparam [#read] io the wrapped IO object.
# File lib/grack/io_streamer.rb, line 41 def with_io yield(@io) end