class Tar::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/archive/tar/minitar/writer.rb, line 30 def self.const_missing(c) case c when :FileOverflow warn 'Writer::BoundedWriteStream::FileOverflow has been renamed ' \ 'to Writer::WriteBoundaryOverflow' const_set :FileOverflow, Archive::Tar::Minitar::Writer::WriteBoundaryOverflow else super end end
new(io, limit)
click to toggle source
# File lib/archive/tar/minitar/writer.rb, line 48 def initialize(io, limit) @io = io @limit = limit @written = 0 end
Public Instance Methods
write(data)
click to toggle source
# File lib/archive/tar/minitar/writer.rb, line 54 def write(data) size = bytesize(data) raise WriteBoundaryOverflow if (size + @written) > @limit @io.write(data) @written += size size end