| Class | Gem::Package::TarWriter::BoundedStream |
| In: |
lib/rubygems/package/tar_writer.rb
|
| Parent: | Object |
| limit | [R] | Maximum number of bytes that can be written |
| written | [R] | Number of bytes written |
Wraps io and allows up to limit bytes to be written
# File lib/rubygems/package/tar_writer.rb, line 32
32: def initialize(io, limit)
33: @io = io
34: @limit = limit
35: @written = 0
36: end
Writes data onto the IO, raising a FileOverflow exception if the number of bytes will be more than limit
# File lib/rubygems/package/tar_writer.rb, line 42
42: def write(data)
43: if data.size + @written > @limit
44: raise FileOverflow, "You tried to feed more data than fits in the file."
45: end
46: @io.write data
47: @written += data.size
48: data.size
49: end