Class: Cabriolet::Decompressors::Base

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

Overview

Base class for all decompression algorithms

Direct Known Subclasses

LZSS, LZX, MSZIP, None, Quantum

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io_system, input, output, buffer_size) ⇒ Base

Initialize a new decompressor

Parameters:



15
16
17
18
19
20
# File 'lib/cabriolet/decompressors/base.rb', line 15

def initialize(io_system, input, output, buffer_size)
  @io_system = io_system
  @input = input
  @output = output
  @buffer_size = buffer_size
end

Instance Attribute Details

#buffer_sizeObject (readonly)

Returns the value of attribute buffer_size.



7
8
9
# File 'lib/cabriolet/decompressors/base.rb', line 7

def buffer_size
  @buffer_size
end

#inputObject (readonly)

Returns the value of attribute input.



7
8
9
# File 'lib/cabriolet/decompressors/base.rb', line 7

def input
  @input
end

#io_systemObject (readonly)

Returns the value of attribute io_system.



7
8
9
# File 'lib/cabriolet/decompressors/base.rb', line 7

def io_system
  @io_system
end

#outputObject (readonly)

Returns the value of attribute output.



7
8
9
# File 'lib/cabriolet/decompressors/base.rb', line 7

def output
  @output
end

Instance Method Details

#decompress(bytes) ⇒ Integer

Decompress the specified number of bytes

Parameters:

  • bytes (Integer)

    Number of bytes to decompress

Returns:

  • (Integer)

    Number of bytes decompressed

Raises:

  • (NotImplementedError)

    Must be implemented by subclasses



27
28
29
# File 'lib/cabriolet/decompressors/base.rb', line 27

def decompress(bytes)
  raise NotImplementedError, "#{self.class} must implement #decompress"
end

#freevoid

This method returns an undefined value.

Free any resources used by the decompressor



34
35
36
# File 'lib/cabriolet/decompressors/base.rb', line 34

def free
  # Override in subclasses if cleanup needed
end