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 31
31:     def initialize(io, limit)
32:       @io = io
33:       @limit = limit
34:       @written = 0
35:     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 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

[Validate]