Class: Ronin::Support::Compression::Gzip::Writer

Inherits:
Zlib::GzipWriter
  • Object
show all
Defined in:
lib/ronin/support/compression/gzip/writer.rb

Overview

Handles writing gzip compressed data.

Instance Method Summary collapse

Constructor Details

#initialize(io_or_buffer, mode: 'w') ⇒ Writer

Initializes the gzip writer.

Examples:

Initializing with an IO object:

gzip = Compression::Gzip::Writer.new(io)

Initializing with a buffer:

buffer = ""
gzip   = Compression::Gzip::Writer.new(buffer)

Initializin with a buffer and append mode:

buffer = "foo"
gzip   = Compression::Gzip::Writer.new(buffer, mode: 'a')

Parameters:

  • io_or_buffer (IO, StringIO, String)

    The IO object or buffer to write to. If a String is given, then it will be wrapped in a StringIO object using the optional mode argument.

  • mode (String) (defaults to: 'w')

    The optional mode to initialize the StringIO object to wrap around the given buffer String.

Since:

  • 1.0.0



61
62
63
64
65
66
67
68
# File 'lib/ronin/support/compression/gzip/writer.rb', line 61

def initialize(io_or_buffer, mode: 'w')
  io = case io_or_buffer
       when String then StringIO.new(io_or_buffer,mode)
       else             io_or_buffer
       end

  super(io)
end