Class: Yajl::Gzip::StreamReader
- Defined in:
- lib/yajl/gzip/stream_reader.rb
Overview
This is a wrapper around Zlib::GzipReader to allow it’s #read method to adhere to the IO spec, allowing for two parameters (length, and buffer)
Class Method Summary collapse
-
.parse(input, options = {}, buffer_size = nil, &block) ⇒ Object
Helper method for one-off parsing from a gzip-compressed stream.
Instance Method Summary collapse
-
#read(len = nil, buffer = nil) ⇒ Object
A helper method to allow use similar to IO#read.
Class Method Details
.parse(input, options = {}, buffer_size = nil, &block) ⇒ Object
Helper method for one-off parsing from a gzip-compressed stream
See Yajl::Parser#parse for parameter documentation
22 23 24 25 26 27 |
# File 'lib/yajl/gzip/stream_reader.rb', line 22 def self.parse(input, ={}, buffer_size=nil, &block) if input.is_a?(String) input = StringIO.new(input) end Yajl::Parser.new().parse(new(input), buffer_size, &block) end |
Instance Method Details
#read(len = nil, buffer = nil) ⇒ Object
A helper method to allow use similar to IO#read
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/yajl/gzip/stream_reader.rb', line 7 def read(len=nil, buffer=nil) if val = super(len) unless buffer.nil? buffer.replace(val) return buffer end super(len) else nil end end |