Class Barby::EAN13
In: lib/barby/barcode/ean_13.rb
Parent: Barcode1D

EAN-13, aka UPC-A, barcodes are the ones you can see at your local supermarket, in your house and, well, everywhere..

To use this for a UPC barcode, just add a 0 to the front

Methods

Constants

LEFT_ENCODINGS_ODD = { 0 => '0001101', 1 => '0011001', 2 => '0010011', 3 => '0111101', 4 => '0100011', 5 => '0110001', 6 => '0101111', 7 => '0111011', 8 => '0110111', 9 => '0001011'
LEFT_ENCODINGS_EVEN = { 0 => '0100111', 1 => '0110011', 2 => '0011011', 3 => '0100001', 4 => '0011101', 5 => '0111001', 6 => '0000101', 7 => '0010001', 8 => '0001001', 9 => '0010111'
RIGHT_ENCODINGS = { 0 => '1110010', 1 => '1100110', 2 => '1101100', 3 => '1000010', 4 => '1011100', 5 => '1001110', 6 => '1010000', 7 => '1000100', 8 => '1001000', 9 => '1110100'
LEFT_PARITY_MAPS = { 0 => [:odd, :odd, :odd, :odd, :odd, :odd], #UPC-A 1 => [:odd, :odd, :even, :odd, :even, :even], 2 => [:odd, :odd, :even, :even, :odd, :even], 3 => [:odd, :odd, :even, :even, :even, :odd], 4 => [:odd, :even, :odd, :odd, :even, :even], 5 => [:odd, :even, :even, :odd, :odd, :even], 6 => [:odd, :even, :even, :even, :odd, :odd], 7 => [:odd, :even, :odd, :even, :odd, :even], 8 => [:odd, :even, :odd, :even, :even, :odd], 9 => [:odd, :even, :even, :odd, :even, :odd]   Describes whether the left-hand encoding should use LEFT_ENCODINGS_ODD or LEFT_ENCODINGS_EVEN, based on the first digit in the number system (and the barcode as a whole)
START = '101'   These are the lines that "stick down" in the graphical representation
CENTER = '01010'
STOP = '101'
FORMAT = /^\d{12}$/   EAN-13 barcodes have 12 digits + check digit

Attributes

data  [RW] 

Public Class methods

Public Instance methods

Numbers that are encoded to the left of the center The first digit is not included

The parities to use for encoding left-hand numbers

Numbers that are encoded to the right of the center The checksum is included here

Is this a UPC-A barcode? UPC barcodes are EAN codes that start with 0

[Validate]