Class: TreasureData::FileReader::DecompressIOFilter
- Inherits:
-
Object
- Object
- TreasureData::FileReader::DecompressIOFilter
- Defined in:
- lib/td/file_reader.rb
Class Method Summary collapse
Class Method Details
.filter(io, error, opts) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/td/file_reader.rb', line 17 def self.filter(io, error, opts) case opts[:compress] when 'gzip' return Zlib::GzipReader.new(io) when 'plain' return io when nil data = io.read(2) io.rewind if data.unpack('CC') == [0x1f, 0x8b] return Zlib::GzipReader.new(io) else return io end else raise "unknown compression type #{opts[:compress]}" end end |