Module: Vedeu::Output::CompressorCache Private
- Extended by:
- CompressorCache, Repositories::Storage
- Included in:
- CompressorCache
- Defined in:
- lib/vedeu/output/compressor_cache.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Store a copy of the data last processed by Compressor. Both the original content and the compressed versions are kept (unless modified) to speed up the rendering of the display.
Instance Method Summary collapse
- #cache(content, compression = false) ⇒ String private
- #cached?(content) ⇒ Boolean private private
- #compress(content) ⇒ String private private
- #empty?(content) ⇒ Boolean private private
- #in_memory ⇒ Hash<Symbol => Array<void>, String> private private
- #read(key) ⇒ Array<void> private private
- #same?(content) ⇒ Boolean private private
- #size?(content) ⇒ Boolean private private
- #uncompress(content) ⇒ String private private
- #write(content) ⇒ Hash<Symbol => Array<void>> private private
Methods included from Repositories::Storage
Instance Method Details
#cache(content, compression = false) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 24 25 |
# File 'lib/vedeu/output/compressor_cache.rb', line 21 def cache(content, compression = false) write(content) unless empty?(content) || cached?(content) compression ? read(:compress) : read(:uncompress) end |
#cached?(content) ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/vedeu/output/compressor_cache.rb', line 31 def cached?(content) size?(content) && same?(content) end |
#compress(content) ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/vedeu/output/compressor_cache.rb', line 49 def compress(content) Vedeu::Output::Compressors::Character.with(content) end |
#empty?(content) ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/vedeu/output/compressor_cache.rb', line 55 def empty?(content) content.nil? || content.empty? end |
#in_memory ⇒ Hash<Symbol => Array<void>, String> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 65 66 |
# File 'lib/vedeu/output/compressor_cache.rb', line 60 def in_memory { compress: '', original: [], uncompress: '', } end |
#read(key) ⇒ Array<void> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 |
# File 'lib/vedeu/output/compressor_cache.rb', line 70 def read(key) storage.fetch(key, []) end |
#same?(content) ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/vedeu/output/compressor_cache.rb', line 43 def same?(content) content == read(:original) end |
#size?(content) ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'lib/vedeu/output/compressor_cache.rb', line 37 def size?(content) content.size == read(:original).size end |
#uncompress(content) ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/vedeu/output/compressor_cache.rb', line 76 def uncompress(content) Vedeu::Output::Compressors::Simple.with(content) end |
#write(content) ⇒ Hash<Symbol => Array<void>> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
82 83 84 85 86 87 88 |
# File 'lib/vedeu/output/compressor_cache.rb', line 82 def write(content) storage[:original] = content storage[:uncompress] = uncompress(content) storage[:compress] = compress(content) end |