本文簡要介紹ruby語言中 Zlib::Inflate.inflate
的用法。
用法
inflate(deflate_string, buffer: nil) → String
inflate(deflate_string, buffer: nil) { |chunk| ... } → nil
將deflate_string
輸入到膨脹流中並返回流的輸出。調用此方法,流的輸入和輸出緩衝區都被刷新。如果 string 是 nil
,則此方法完成流,就像 Zlib::ZStream#finish
一樣。
如果給定一個塊,則來自deflate_string
的連續膨脹塊將屈服於該塊並返回nil
。
如果給出了 a:buffer 關鍵字參數而不是 nil:
-
:buffer 關鍵字應該是
String
,並將用作輸出緩衝區。使用此選項可以重用膨脹期間所需的內存。 -
不傳遞塊時,返回值將是與:buffer 關鍵字參數相同的對象。
-
當傳遞一個塊時,產生的塊將與:buffer 關鍵字參數的值相同。
如果需要預設字典來解壓縮,則會引發 Zlib::NeedDict
異常。 Set
Zlib::Inflate#set_dictionary
的字典,然後用空字符串再次調用此方法以刷新流:
inflater = Zlib::Inflate.new
begin
out = inflater.inflate compressed
rescue Zlib::NeedDict
# ensure the dictionary matches the stream's required dictionary
raise unless inflater.adler == Zlib.adler32(dictionary)
inflater.set_dictionary dictionary
inflater.inflate ''
end
# ...
inflater.close
相關用法
- Ruby Inflate.inflate用法及代碼示例
- Ruby Inflate.new用法及代碼示例
- Ruby Inflate.sync_point?用法及代碼示例
- Ruby Integer.nobits?用法及代碼示例
- Ruby Integer lcm()用法及代碼示例
- Ruby Integer.self >=用法及代碼示例
- Ruby Integer.self >>用法及代碼示例
- Ruby Integer.next用法及代碼示例
- Ruby Integer.self ** numeric用法及代碼示例
- Ruby Integer integer?用法及代碼示例
- Ruby Integer.truncate用法及代碼示例
- Ruby Integer digits用法及代碼示例
- Ruby Integer divmod()用法及代碼示例
- Ruby Integer floor()用法及代碼示例
- Ruby Integer.sqrt用法及代碼示例
- Ruby Integer to_f用法及代碼示例
- Ruby Integer to_s用法及代碼示例
- Ruby Integer.bit_length用法及代碼示例
- Ruby InstructionSequence.base_label用法及代碼示例
- Ruby Integer times用法及代碼示例
- Ruby Integer truncate()用法及代碼示例
- Ruby Integer remainder()用法及代碼示例
- Ruby Integer.floor用法及代碼示例
- Ruby Integer.pred用法及代碼示例
- Ruby Integer.gcd用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 Inflate.inflate。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。