Class BZ2::Reader
In: bz2.rb
Parent: Object

The class for decompressing data. Data can be read directly from a String, or from an object which must respond to read

Methods
allocate    close    close!    closed?    each    each_line    eof    eoz    finish    foreach    getc    gets    lineno    lineno=    new    new    open    read    readline    readlines    readlines    to_io    ungetc    ungets    unused    unused=   
Included modules
Enumerable
Public Class methods
allocate()

allocate a new BZ2::Reader

foreach(filename, separator = $/) {|line| ...}

Uncompress the file and call the block for each line, where lines are separated by separator

new(object, small = false)

Associate a new bz2 reader with object. object must respond to read

See initialize for small

open(filename, small = false) {|bz2| ...}

Call Kernel#open(filename), and associate it a new BZ2::Reader. The bz2 object is passed as an argument to the block.

The object is closed at the end of the block

See initialize for small

readlines(filename, separator = $/)

Uncompress the file and reads the entire file as individual lines, and returns those lines in an array. Lines are separated by separator

new(object, small = false)

object must be a String which contains compressed data, or an object which respond to read(size)

If small is true, the library will use an alternative decompression algorithm which uses less memory but at the cost of decompressing more slowly

Public Instance methods
close()

Terminate the uncompression and close the bz2

close!()

Terminate the uncompression, close the bz2 and the associated object

closed?()

Return true if the file is closed

each(separator = $/) {|line| ...}

Execute the block for each line, where lines are separated by the optional separator

each_line(separator = $/) {|line| ...}

same than each

eof()

Return true at end of file

eoz()

"End Of Zip". Return true at the end of the zip component

finish()

Terminate the uncompression of the current zip component, and keep the bz2 active (to read another zip component)

getc()

Get the next 8-bit byte (0..255). Returns nil if called at end of file.

gets(separator = $/)

Reads the next line; lines are separated by separator. Returns nil if called at end of file.

lineno()

Return the current line number

lineno=(num)

Manually sets the current line number to the given value

read(number)

Read at most number characters Returns nil if called at end of file

readline(separator = $/)

Reads the next line; lines are separated by separator. Raise an error at end of file

readlines(separator = $/)

Reads all of the lines, and returns them in anArray. Lines are separated by the optional separator

to_io()

return the associated object

ungetc(char)

Push back one character

ungets(str)

Push back the string

unused()

Return the String read by BZ2::Reader but not used in the uncompression

unused=(str)

Initialize the uncompression with the String str