Class: Cabriolet::Decompressors::None

Inherits:
Base
  • Object
show all
Defined in:
lib/cabriolet/decompressors/none.rb

Overview

None handles uncompressed data (no compression)

Instance Attribute Summary

Attributes inherited from Base

#buffer_size, #input, #io_system, #output

Instance Method Summary collapse

Methods inherited from Base

#free, #initialize

Constructor Details

This class inherits a constructor from Cabriolet::Decompressors::Base

Instance Method Details

#decompress(bytes) ⇒ Integer

Decompress (copy) the specified number of bytes

Parameters:

  • bytes (Integer)

    Number of bytes to copy

Returns:

  • (Integer)

    Number of bytes copied



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cabriolet/decompressors/none.rb', line 11

def decompress(bytes)
  total_copied = 0

  while total_copied < bytes
    chunk_size = [bytes - total_copied, @buffer_size].min
    data = @io_system.read(@input, chunk_size)
    break if data.empty?

    @io_system.write(@output, data)
    total_copied += data.bytesize
  end

  total_copied
end