module SimpleCompress
Constants
- VERSION
Public Instance Methods
compress(binary_string)
click to toggle source
Compress a given binary string into a binary stringthat is usable as content for a .gz file.
# File lib/simple_compress.rb, line 7 def compress(binary_string) buf = StringIO.new gz = Zlib::GzipWriter.new(buf) gz.write(binary_string) gz.close buf.string.force_encoding(Encoding::BINARY) end
expand(binary_string)
click to toggle source
Expand a given .gz binary string to it’s original size Simple explanation at stackoverflow.com/questions/1361892/how-to-decompress-gzip-string-in-ruby
# File lib/simple_compress.rb, line 17 def expand(binary_string) buf = StringIO.new(binary_string) z = Zlib::GzipReader.new(buf) z.read end