Class: Nanoc::Core::TextualCompiledContentCache::LazyCompressedValue Private

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/core/textual_compiled_content_cache.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(uncompressed: nil, compressed: nil) ⇒ LazyCompressedValue

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.

Returns a new instance of LazyCompressedValue.



13
14
15
16
17
18
19
20
# File 'lib/nanoc/core/textual_compiled_content_cache.rb', line 13

def initialize(uncompressed: nil, compressed: nil)
  if uncompressed.nil? && compressed.nil?
    raise ArgumentError, 'must specify at least uncompressed or compressed'
  end

  @_uncompressed = uncompressed
  @_compressed = compressed
end

Instance Method Details

#compressedObject

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.



22
23
24
# File 'lib/nanoc/core/textual_compiled_content_cache.rb', line 22

def compressed
  @_compressed ||= Zlib::Deflate.deflate(Marshal.dump(@_uncompressed), Zlib::BEST_SPEED)
end

#marshal_dumpObject

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.



30
31
32
# File 'lib/nanoc/core/textual_compiled_content_cache.rb', line 30

def marshal_dump
  [compressed]
end

#marshal_load(array) ⇒ Object

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.



34
35
36
37
# File 'lib/nanoc/core/textual_compiled_content_cache.rb', line 34

def marshal_load(array)
  @_compressed = array[0]
  @_uncompressed = nil
end

#uncompressedObject

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.



26
27
28
# File 'lib/nanoc/core/textual_compiled_content_cache.rb', line 26

def uncompressed
  @_uncompressed ||= Marshal.load(Zlib::Inflate.inflate(@_compressed))
end