module Ronin::Support::Compression::Mixin
Provides helper methods for compression algorithms/formats.
@api public
@since 1.0.0
Public Instance Methods
Opens the gzipped file for reading.
@param [String] path
The path to the file to read.
@yield [gz]
If a block is given, it will be passed the gzip reader object.
@yieldparam [Ronin::Support::Compression::Gzip::Reader] gz
The gzip reader object.
@return [Ronin::Support::Compression::Gzip::Reader]
The gzip reader object.
@see gzip_open
@api public
# File lib/ronin/support/compression/mixin.rb, line 151 def gunzip(path,&block) Compression.gunzip(path,&block) end
Opens the gzip file for writing.
@param [String] path
The path to the file to write to.
@yield [gz]
If a block is given, it will be passed the gzip writer object.
@yieldparam [Ronin::Support::Compression::Gzip::Writer] gz
The gzip writer object.
@return [Ronin::Support::Compression::Gzip::Writer]
The gzip writer object.
@see gzip_open
@api public
# File lib/ronin/support/compression/mixin.rb, line 174 def gzip(path,&block) Compression.gzip(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 [Ronin::Support::Compression::Gzip::Reader, Ronin::Support::Compression::Gzip::Writer
] gz
The gzip stream object.
@return [Ronin::Support::Compression::Gzip::Reader, Ronin::Support::Compression::Gzip::Writer
]
The gzip stream object.
@raise [ArgumentError]
The mode must include either `r`, `w`, or `a`.
@see rubydoc.info/stdlib/zlib/Zlib/GzipWriter @see Gzip.open
@api public
# File lib/ronin/support/compression/mixin.rb, line 128 def gzip_open(path, mode: 'r', &block) Compression.gzip_open(path,mode: mode,&block) end
Creates a gzip stream around the IO
object.
@param [IO, Tempfile, StringIO, String] io
The IO 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 [Ronin::Support::Compression::Gzip::Reader, Ronin::Support::Compression::Gzip::Writer
] gz
The gzip reader or writer object.
@return [Ronin::Support::Compression::Gzip::Reader, Ronin::Support::Compression::Gzip::Writer
]
The gzip reader or writer object.
@raise [ArgumentError]
The IO object must be either an `IO`, `Tempfile`, `StringIO`, or `String` object. The mode must include either `r`, `w`, or `a`.
@see rubydoc.info/stdlib/zlib/Zlib/GzipReader @see rubydoc.info/stdlib/zlib/Zlib/GzipWriter @see Gzip.new
@api public
# File lib/ronin/support/compression/mixin.rb, line 98 def gzip_stream(io, mode: 'r', &block) Compression.gzip_stream(io,mode: mode,&block) end
Zlib
deflate a string.
@param [String] string
The uncompressed input.
@return [String]
The Zlib deflated form of the input.
@example
zlib_deflate("hello") # => "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15"
@api public
# File lib/ronin/support/compression/mixin.rb, line 66 def zlib_deflate(string) Compression.zlib_deflate(string) end
Zlib
inflate a string.
@param [String] string
The Zlib compressed input.
@return [String]
The Zlib inflated form of the input.
@example
zlib_inflate("x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15") # => "hello"
@api public
# File lib/ronin/support/compression/mixin.rb, line 47 def zlib_inflate(string) Compression.zlib_inflate(string) end