| 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 31
31: def initialize(io, limit)
32: @io = io
33: @limit = limit
34: @written = 0
35: 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 41
41: def write(data)
42: if data.size + @written > @limit
43: raise FileOverflow, "You tried to feed more data than fits in the file."
44: end
45: @io.write data
46: @written += data.size
47: data.size
48: end