class Minitar::Writer::BoundedWriteStream
A WriteOnlyStream
that also has a size limit.
Attributes
limit[R]
The maximum number of bytes that may be written to this data stream.
written[R]
The current total number of bytes written to this data stream.
Public Class Methods
const_missing(c)
click to toggle source
Calls superclass method
# File lib/minitar/writer.rb, line 24 def self.const_missing(c) case c when :FileOverflow warn "Writer::BoundedWriteStream::FileOverflow has been renamed " \ "to Writer::WriteBoundaryOverflow" const_set :FileOverflow, Minitar::Writer::WriteBoundaryOverflow else super end end
new(io, limit)
click to toggle source
# File lib/minitar/writer.rb, line 42 def initialize(io, limit) @io = io @limit = limit @written = 0 end
Public Instance Methods
write(data)
click to toggle source
# File lib/minitar/writer.rb, line 48 def write(data) size = data.bytesize raise WriteBoundaryOverflow if (size + @written) > @limit @io.write(data) @written += size size end