Module: TreasureData::API::DeflateReadBodyMixin

Defined in:
lib/td/client/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gzipObject

Returns the value of attribute gzip.



1199
1200
1201
# File 'lib/td/client/api.rb', line 1199

def gzip
  @gzip
end

Instance Method Details

#each_fragment(&block) ⇒ Object



1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
# File 'lib/td/client/api.rb', line 1201

def each_fragment(&block)
  if @gzip
    infl = Zlib::Inflate.new(Zlib::MAX_WBITS + 16)
  else
    infl = Zlib::Inflate.new
  end
  begin
    read_body {|fragment|
      block.call infl.inflate(fragment)
    }
  ensure
    infl.close
  end
  nil
end