Class: Digest::CRC1

Inherits:
CRC
  • Object
show all
Defined in:
lib/digest/crc1.rb

Overview

Implements the CRC1 algorithm.

Constant Summary

Constants inherited from CRC

Digest::CRC::INIT_CRC, Digest::CRC::TABLE, Digest::CRC::WIDTH, Digest::CRC::XOR_MASK

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CRC

#<<, #block_length, checksum, #checksum, #digest_length, #finish, #initialize, #reset

Constructor Details

This class inherits a constructor from Digest::CRC

Class Method Details

.pack(crc) ⇒ String

Packs the CRC1 checksum.

Returns:

  • (String)

    The CRC1 checksum.



15
16
17
# File 'lib/digest/crc1.rb', line 15

def self.pack(crc)
  [crc].pack('c*')
end

Instance Method Details

#update(data) ⇒ Object

Updates the CRC1 checksum.

Parameters:

  • data (String)

    The data to update the checksum with.



25
26
27
28
29
30
31
32
# File 'lib/digest/crc1.rb', line 25

def update(data)
  accum = 0
  data.each_byte { |b| accum += b }

  @crc += (accum % 256)

  return self
end