Class: Cabriolet::Compressors::Base

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

Overview

Base class for all compression algorithms

Provides common interface and functionality for compressors. Each compressor implementation must override the compress method.

Direct Known Subclasses

LZSS, LZX, MSZIP, Quantum

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initialize base compressor

Parameters:



18
19
20
21
22
23
# File 'lib/cabriolet/compressors/base.rb', line 18

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.



10
11
12
# File 'lib/cabriolet/compressors/base.rb', line 10

def buffer_size
  @buffer_size
end

#inputObject (readonly)

Returns the value of attribute input.



10
11
12
# File 'lib/cabriolet/compressors/base.rb', line 10

def input
  @input
end

#io_systemObject (readonly)

Returns the value of attribute io_system.



10
11
12
# File 'lib/cabriolet/compressors/base.rb', line 10

def io_system
  @io_system
end

#outputObject (readonly)

Returns the value of attribute output.



10
11
12
# File 'lib/cabriolet/compressors/base.rb', line 10

def output
  @output
end

Instance Method Details

#compressInteger

Compress the input data

Returns:

  • (Integer)

    Number of bytes written

Raises:

  • (NotImplementedError)

    Must be implemented by subclasses



29
30
31
# File 'lib/cabriolet/compressors/base.rb', line 29

def compress
  raise NotImplementedError, "#{self.class} must implement #compress"
end