This is a wrapper around Zlib::Inflate, creating a # method that adheres to the IO spec, allowing for two parameters (length, and buffer)
Wrapper to the initialize method so we can set the initial IO to parse from.
# File lib/yajl/deflate/stream_reader.rb, line 9
9: def initialize(io, options)
10: @io = io
11: super(options)
12: end
Helper method for one-off parsing from a deflate-compressed stream
See Yajl::Parser#parse for parameter documentation
# File lib/yajl/deflate/stream_reader.rb, line 30
30: def self.parse(input, options={}, buffer_size=nil, &block)
31: if input.is_a?(String)
32: input = StringIO.new(input)
33: end
34:
35: if options.is_a?(Hash)
36: deflate_options = options.delete(:deflate_options)
37: Yajl::Parser.new(options).parse(new(input, deflate_options), buffer_size, &block)
38: elsif options.is_a?(Fixnum)
39: Yajl::Parser.new.parse(new(input, options), buffer_size, &block)
40: end
41: end
A helper method to allow use similar to IO#read
# File lib/yajl/deflate/stream_reader.rb, line 15
15: def read(len=nil, buffer=nil)
16: if val = @io.read(len)
17: unless buffer.nil?
18: buffer.replace(inflate(val))
19: return buffer
20: end
21: inflate(@io.read(len))
22: else
23: nil
24: end
25: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.