module Ronin::Support::Compression::Gzip
Handles gzip compression/decompression.
@api public
@since 1.0.0
Public Class Methods
Source
# File lib/ronin/support/compression/gzip.rb, line 56 def self.new(io, mode: 'r', &block) gzip_class = if mode.include?('w') || mode.include?('a') Writer elsif mode.include?('r') Reader else raise(ArgumentError,"mode argument must include either 'r', 'w', or 'a': #{mode.inspect}") end return gzip_class.wrap(io,&block) end
Creates a gzip stream around the IO
object.
@param [IO, StringIO, String] io
The IO or buffer object to read or write data to.
@param [String] mode
The mode to open the gzip stream in.
@yield [gz]
If a block is given, it will be passed the gzip stream object.
@yieldparam [Reader, Writer] gz
The gzip reader or writer object.
@return [Reader, Writer]
The gzip reader or writer object.
@raise [ArgumentError]
The mode must include either `r`, `w`, or `a`.
@api public
Source
# File lib/ronin/support/compression/gzip.rb, line 91 def self.open(path, mode: 'r', &block) gzip_class = if mode.include?('w') || mode.include?('a') Writer elsif mode.include?('r') Reader else raise(ArgumentError,"mode argument must include either 'r', 'w', or 'a'") end return gzip_class.open(path,&block) end
Opens a gzip file for reading or writing.
@param [String] path
The path to the gzip file.
@param [String] mode
The mode to open the file as.
@yield [gz]
If a block is given, it will be passed the gzip writer object.
@yieldparam [Reader, Writer] gz
The gzip writer object.
@return [Reader, Writer]
The gzip writer object.
@raise [ArgumentError]
The mode must include either `r`, `w`, or `a`.
@api public