class Yajl::Bzip2::StreamReader

to the IO spec, allowing for two parameters (length, and buffer)
This is a wrapper around Bzip::Reader to allow it’s #read method to adhere

def self.parse(input, options={}, buffer_size=nil, &block)

See Yajl::Parser#parse for parameter documentation

Helper method for one-off parsing from a bzip2-compressed stream
def self.parse(input, options={}, buffer_size=nil, &block)
  if input.is_a?(String)
    input = StringIO.new(input)
  end
  Yajl::Parser.new(options).parse(new(input), buffer_size, &block)
end

def read(len=nil, buffer=nil)

A helper method to allow use similar to IO#read
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