Class: Sidetree::Model::CASFileBase
- Inherits:
-
Object
- Object
- Sidetree::Model::CASFileBase
- Includes:
- Util::Compressor
- Defined in:
- lib/sidetree/model/cas_file_base.rb
Direct Known Subclasses
ChunkFile, CoreIndexFile, CoreProofFile, ProvisionalIndexFile, ProvisionalProofFile
Constant Summary
Constants included from Util::Compressor
Util::Compressor::ESTIMATE_DECOMPRESSION_MULTIPLIER
Class Method Summary collapse
-
.decompress(data, max_size) ⇒ String
Decompress
data
.
Instance Method Summary collapse
-
#to_compress ⇒ String
Generate compressed data via to_json to be stored in CAS.
-
#to_json ⇒ String
Build json string to be stored in CAS.
Methods included from Util::Compressor
Class Method Details
.decompress(data, max_size) ⇒ String
Decompress data
.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sidetree/model/cas_file_base.rb', line 11 def self.decompress(data, max_size) begin Sidetree::Util::Compressor.decompress( data, max_bytes: max_size * Sidetree::Util::Compressor::ESTIMATE_DECOMPRESSION_MULTIPLIER ) rescue Zlib::GzipFile::Error raise Sidetree::Error, "#{self.name.split("::").last.split(/(?=[A-Z])/).join(" ")} decompression failure" end end |
Instance Method Details
#to_compress ⇒ String
Generate compressed data via to_json to be stored in CAS.
35 36 37 |
# File 'lib/sidetree/model/cas_file_base.rb', line 35 def to_compress compress(to_json) end |
#to_json ⇒ String
Build json string to be stored in CAS. Child classes must implement this method.
28 29 30 31 |
# File 'lib/sidetree/model/cas_file_base.rb', line 28 def to_json raise NotImplementedError, "You must implement #{self.class}##{__method__}" end |