Type:
Class

Zlib::GzipReader is the class for reading a gzipped file. GzipReader should be used an IO, or -IO-like, object.

1
2
3
4
5
6
7
8
9
Zlib::GzipReader.open('hoge.gz') {|gz|
  print gz.read
}
 
File.open('hoge.gz') do |f|
  gz = Zlib::GzipReader.new(f)
  print gz.read
  gz.close
end

Method Catalogue

The following methods in Zlib::GzipReader are just like their counterparts in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an error was found in the gzip file.

Be careful of the footer of the gzip file. A gzip file has the checksum of pre-compressed data in its footer. GzipReader checks all uncompressed data against that checksum at the following cases, and if it fails, raises Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or Zlib::GzipFile::LengthError exception.

  • When an reading request is received beyond the end of file (the end of compressed data). That is, when #read, #gets, or some other methods for reading returns nil.

  • When Zlib::GzipFile#close method is called after the object reaches the end of file.

  • When #unused method is called after the object reaches the end of file.

The rest of the methods are adequately described in their own documentation.

tell
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

tell() Instance Public methods Total number of output bytes output so far.

2025-01-10 15:47:30
each_char
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

each_char() Instance Public methods See

2025-01-10 15:47:30
readbyte
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

readbyte() Instance Public methods See

2025-01-10 15:47:30
lineno
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

lineno() Instance Public methods The line number of the last row read from this

2025-01-10 15:47:30
rewind
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

rewind() Instance Public methods Resets the position of the file pointer to

2025-01-10 15:47:30
new
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

Zlib::GzipReader.new(io, options = {}) Class Public methods Creates a

2025-01-10 15:47:30
each_byte
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

each_byte() Instance Public methods See

2025-01-10 15:47:30
readlines
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

readlines(*args) Instance Public methods See

2025-01-10 15:47:30
pos
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

pos() Instance Public methods Total number of output bytes output so far.

2025-01-10 15:47:30
gets
  • References/Ruby on Rails/Ruby/Classes/Zlib/Zlib::GzipReader

gets(*args) Instance Public methods See

2025-01-10 15:47:30