Class: Imb::Crc
- Inherits:
-
Object
- Object
- Imb::Crc
- Includes:
- NumericConversions
- Defined in:
- lib/USPS-intelligent-barcode/crc.rb
Overview
Calculates the Intelligent Mail Barcode CRC.
Internal collapse
-
#crc(binary_data) ⇒ Integer
Calculate a CRC.
Methods included from NumericConversions
Instance Method Details
#crc(binary_data) ⇒ Integer
Calculate a CRC.
17 18 19 20 21 22 23 24 25 |
# File 'lib/USPS-intelligent-barcode/crc.rb', line 17 def crc(binary_data) crc = MASK bytes = numeric_to_bytes(binary_data, NUM_INPUT_BYTES) crc = crc_byte(crc, bytes.first, LEADING_BITS_TO_IGNORE) for byte in bytes[1...NUM_INPUT_BYTES] crc = crc_byte(crc, byte, 0) end crc end |