Class: Yajl::Deflate::StreamWriter

Inherits:
Zlib::Deflate
  • Object
show all
Defined in:
lib/yajl/deflate/stream_writer.rb

Overview

A wrapper around the Zlib::Deflate class for easier JSON stream parsing

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) encode(obj, io)

A helper method for one-off encoding to a deflate-compressed stream

Look up Yajl::Encoder#encode for parameter documentation



16
17
18
# File 'lib/yajl/deflate/stream_writer.rb', line 16

def self.encode(obj, io)
  Yajl::Encoder.new.encode(obj, new(io))
end

Instance Method Details

- (Object) write(str)

A helper method to allow use similar to IO#write



8
9
10
11
# File 'lib/yajl/deflate/stream_writer.rb', line 8

def write(str)
  deflate(str)
  str.size unless str.nil?
end