Class Gem::Package::TarWriter::BoundedStream
In: lib/rubygems/package/tar_writer.rb
Parent: Object

IO wrapper that allows writing a limited amount of data

Methods

new   write  

Attributes

limit  [R]  Maximum number of bytes that can be written
written  [R]  Number of bytes written

Public Class methods

Wraps io and allows up to limit bytes to be written

[Source]

    # 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

Public Instance methods

Writes data onto the IO, raising a FileOverflow exception if the number of bytes will be more than limit

[Source]

    # 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

[Validate]