Class: Schlepp::Sink::TableObject::Compressor::Stream
- Inherits:
-
Object
- Object
- Schlepp::Sink::TableObject::Compressor::Stream
- Defined in:
- lib/schlepp/sink/filter/compressor/stream.rb
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize ⇒ Stream
constructor
A new instance of Stream.
- #length ⇒ Object
- #to_s ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize ⇒ Stream
Returns a new instance of Stream.
8 9 10 11 12 |
# File 'lib/schlepp/sink/filter/compressor/stream.rb', line 8 def initialize @buffer = StringIO.new("", "rb+") @compressor = Zlib::GzipWriter.new(@buffer) @dead = false end |
Instance Method Details
#finalize ⇒ Object
28 29 30 31 32 33 |
# File 'lib/schlepp/sink/filter/compressor/stream.rb', line 28 def finalize if !@dead @compressor.close @dead = true end end |
#length ⇒ Object
21 22 23 24 25 26 |
# File 'lib/schlepp/sink/filter/compressor/stream.rb', line 21 def length if @dead raise "Stream has been dumped. No more writing permitted." end @compressor.pos end |
#to_s ⇒ Object
35 36 37 38 |
# File 'lib/schlepp/sink/filter/compressor/stream.rb', line 35 def to_s finalize @buffer.string end |
#write(data) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/schlepp/sink/filter/compressor/stream.rb', line 14 def write(data) if @dead raise "Stream has been dumped. No more writing permitted." end @compressor << data end |