Class: ZipTricks::Streamer::Writable

Inherits:
Object
  • Object
show all
Defined in:
lib/zip_tricks/streamer/writable.rb

Overview

Gets yielded from the writing methods of the CompressingStreamer and accepts the data being written into the ZIP

Instance Method Summary collapse

Constructor Details

#initialize(writer) ⇒ Writable

Initializes a new Writable with the object it delegates the writes to. Normally you would not need to use this method directly



6
7
8
# File 'lib/zip_tricks/streamer/writable.rb', line 6

def initialize(writer)
  @writer = writer
end

Instance Method Details

#<<(d) ⇒ self

Writes the given data to the output stream

Parameters:

  • d (String)

    the binary string to write (part of the uncompressed file)

Returns:

  • (self)


13
# File 'lib/zip_tricks/streamer/writable.rb', line 13

def <<(d); @writer << d; self; end

#write(d) ⇒ Fixnum

Writes the given data to the output stream

Parameters:

  • d (String)

    the binary string to write (part of the uncompressed file)

Returns:

  • (Fixnum)

    the number of bytes written



19
# File 'lib/zip_tricks/streamer/writable.rb', line 19

def write(d); @writer << d; d.bytesize; end