Class: Archive::Tar::Minitar::Writer::BoundedStream
- Inherits:
-
RestrictedStream
- Object
- RestrictedStream
- Archive::Tar::Minitar::Writer::BoundedStream
- Defined in:
- lib/folio/minitar.rb
Overview
A RestrictedStream that also has a size limit.
Defined Under Namespace
Classes: FileOverflow
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
The maximum number of bytes that may be written to this data stream.
-
#written ⇒ Object
readonly
The current total number of bytes written to this data stream.
Instance Method Summary collapse
-
#initialize(io, limit) ⇒ BoundedStream
constructor
A new instance of BoundedStream.
- #write(data) ⇒ Object
Constructor Details
#initialize(io, limit) ⇒ BoundedStream
354 355 356 357 358 |
# File 'lib/folio/minitar.rb', line 354 def initialize(io, limit) @io = io @limit = limit @written = 0 end |
Instance Attribute Details
#limit ⇒ Object (readonly)
The maximum number of bytes that may be written to this data stream.
350 351 352 |
# File 'lib/folio/minitar.rb', line 350 def limit @limit end |
#written ⇒ Object (readonly)
The current total number of bytes written to this data stream.
352 353 354 |
# File 'lib/folio/minitar.rb', line 352 def written @written end |
Instance Method Details
#write(data) ⇒ Object
360 361 362 363 364 365 |
# File 'lib/folio/minitar.rb', line 360 def write(data) raise FileOverflow if (data.size + @written) > @limit @io.write(data) @written += data.size data.size end |