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

.encode(obj, io) ⇒ Object

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

Look up Yajl::Encoder#encode for parameter documentation


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

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

Instance Method Details

#write(str) ⇒ Object

A helper method to allow use similar to IO#write


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

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