Parent

Methods

Yajl::Deflate::StreamReader

This is a wrapper around Zlib::Inflate, creating a # method that adheres to the IO spec, allowing for two parameters (length, and buffer)

Public Class Methods

new(io, options) click to toggle source

Wrapper to the initialize method so we can set the initial IO to parse from.

    # File lib/yajl/deflate/stream_reader.rb, line 8
 8:       def initialize(io, options)
 9:         @io = io
10:         super(options)
11:       end
parse(input, options={}, buffer_size=nil, &block) click to toggle source

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 29
29:       def self.parse(input, options={}, buffer_size=nil, &block)
30:         if input.is_a?(String)
31:           input = StringIO.new(input)
32:         end
33: 
34:         if options.is_a?(Hash)
35:           deflate_options = options.delete(:deflate_options)
36:           Yajl::Parser.new(options).parse(new(input, deflate_options), buffer_size, &block)
37:         elsif options.is_a?(Fixnum)
38:           Yajl::Parser.new.parse(new(input, options), buffer_size, &block)
39:         end
40:       end

Public Instance Methods

read(len=nil, buffer=nil) click to toggle source

A helper method to allow use similar to IO#read

    # File lib/yajl/deflate/stream_reader.rb, line 14
14:       def read(len=nil, buffer=nil)
15:         if val = @io.read(len)
16:           unless buffer.nil?
17:             buffer.replace(inflate(val))
18:             return buffer
19:           end
20:           inflate(@io.read(len))
21:         else
22:           nil
23:         end
24:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.