Module: Bzip2
- Defined in:
- lib/bzip2.rb,
lib/bzip2/reader.rb,
lib/bzip2/writer.rb,
lib/bzip2/version.rb,
lib/bzip2/internals.rb,
ext/bzip2/bzip2.c
Overview
This file is mostly here for documentation purposes, do not require this
Defined Under Namespace
Classes: EOZError, Error, Reader, Writer
Constant Summary collapse
- VERSION =
"0.2.7"
Class Method Summary collapse
-
.compress(str) ⇒ String
(also: bzip2)
Shortcut for compressing just a string.
-
.uncompress(data) ⇒ String
(also: bunzip2, decompress)
Decompress a string of bz2 compressed data.
Class Method Details
.compress(str) ⇒ String Also known as: bzip2
Shortcut for compressing just a string.
Bzip2.uncompress Bzip2.compress('data') # => 'data'
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'ext/bzip2/bzip2.c', line 55 VALUE bz_compress(VALUE self, VALUE str) { VALUE bz2, argv[1] = {Qnil}; str = rb_str_to_str(str); bz2 = rb_funcall2(bz_cWriter, id_new, 1, argv); if (OBJ_TAINTED(str)) { struct bz_file *bzf; Data_Get_Struct(bz2, struct bz_file, bzf); OBJ_TAINT(bzf->io); } bz_writer_write(bz2, str); return bz_writer_close(bz2); } |
.uncompress(data) ⇒ String Also known as: bunzip2, decompress
Decompress a string of bz2 compressed data.
Bzip2.uncompress Bzip2.compress('asdf') # => 'asdf'
123 124 125 126 127 128 129 |
# File 'ext/bzip2/bzip2.c', line 123 VALUE bz_uncompress(VALUE self, VALUE data) { VALUE bz2, nilv = Qnil, argv[1]; argv[0] = rb_str_to_str(data); bz2 = rb_funcall2(bz_cReader, id_new, 1, argv); return bz_reader_read(1, &nilv, bz2); } |