Module: SBCF

Defined in:
lib/sanger_barcode_format.rb,
lib/sanger_barcode_format/prefix.rb,
lib/sanger_barcode_format/version.rb,
lib/sanger_barcode_format/builders.rb,
lib/sanger_barcode_format/checksum.rb,
lib/sanger_barcode_format/constants.rb,
lib/sanger_barcode_format/legacy_methods.rb,
lib/sanger_barcode_format/sanger_barcode.rb,
lib/sanger_barcode_format/exception_classes.rb

Overview

Constant for namespacing, see README.md or SangerBarcode for documentation

Defined Under Namespace

Modules: Builders, LegacyMethods Classes: Checksum, Prefix, SangerBarcode

Constant Summary collapse

VERSION =

Version number

'0.0.1'.freeze
ASCII_OFFSET =

Subtracted from prefixes byte values during conversion to numbers Results in A having a value of 1

64
PREFIX_BASE =

Used in calculating the prefix. Multiplies the first character in our two byte prefix essentially defining our base. Note: The use of base27 results in a two digit increase between AZ and BA. This behaviour was in the original implementation and has been maintained for reasons of compatibility. I am not aware of the original reasons for the decision.

27
PREFIX_LENGTH =

The digit length of the numeric encoded checksum

3
NUMBER_LENGTH =

The digit length of the unique barcode number

7
CHECKSUM_LENGTH =

The digit length of the internal checksum

2
INTERNAL_LENGTH =

The length of the internally generated portion of the barcode This ignores the print checksum which is internal to the ean13 standard

PREFIX_LENGTH + NUMBER_LENGTH + CHECKSUM_LENGTH
CHECKSUM_ASCII_OFFSET =

The checksum uses a 0 indexed checksum

65
HUMAN_BARCODE_FORMAT =

Regex to match human readable barcodes eg. PR1234K Matches 1: prefix, 2: number, 3: checksum/suffix (optional)

/\A(?<prefix>[A-Z]{2})(?<number>\d{1,7})(?<checksum>[A-Z]{0,1}\z)/
MACHINE_BARCODE_FORMAT =

Regex to match the full ean13 barcode, including all checksums The 2,3 prefix matcher ensures that any barcodes begining with zero are correctly parsed, even if the zero is stripped. Matches 1: Prefix, 2: number 3: suffix 4: ean

/\A(\d{2,3})(\d{7})(\d{2})(\d{1})\z/
BarcodeError =
Class.new(StandardError)
InvalidBarcode =
Class.new(BarcodeError)
ChecksumRequired =
Class.new(BarcodeError)
InvalidBarcodeOperation =
Class.new(BarcodeError)