Class: Bzip2::Reader

Inherits:
Data
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bzip2/reader.rb,
ext/bzip2/bzip2.c

Overview

Bzip2::Reader is meant to read streams of bz2 compressed bytes. It behaves like an IO object with many similar methods. It also includes the Enumerable module and each element is a ‘line’ in the stream.

It can both decompress files:

reader = Bzip2::Reader.open('file')
puts reader.read

reader = Bzip2::Reader.new File.open('file')
put reader.gets

And it may just decompress raw strings

reader = Bzip2::Reader.new compressed_string
reader = Bzip2::Reader.new Bzip2.compress('compress-me')

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObject

Class Method Details

.allocateObject

.foreachObject

.openObject

.readlinesObject

Instance Method Details

#closeObject

#close!Object

#closed?Boolean Also known as: closed

Returns:

  • (Boolean)

#eachObject Also known as: each_line

#each_byteObject

#eof?Boolean Also known as: eof

Returns:

  • (Boolean)

#eoz?Boolean Also known as: eoz

Returns:

  • (Boolean)

#finishObject

#getcObject

#getsObject

#linenoObject

#lineno=Object

#readObject

#readcharObject

#readlineObject

#readlinesObject

#to_ioFile, String

Returns the io stream underlying this stream. If the strem was constructed with a file, that is returned. Otherwise, an empty string is returned.

Returns:

  • (File, String)

    similar to whatever the stream was constructed with

Raises:

  • (IOError)

    if the stream has been closed



76
77
78
79
80
81
# File 'ext/bzip2/bzip2.c', line 76

VALUE bz_to_io(VALUE obj) {
    struct bz_file *bzf;

    Get_BZ2(obj, bzf);
    return bzf->io;
}

#ungetcObject

#ungetsObject

#unusedObject

#unused=Object