CAUTION! This is an early version and may be unstable.
Barcodes generated by Sequencescape and other applications have two representations, a human readable form, and an ean13 representation. The ean13 is regularly used to generate physical barcodes, and is returned by the various barcode scanners. Meanwhile the human readable form is often used when items are searched for manually, particularly when there is no physical access to the item itself.
Barcodes are comprised of three components:
- A prefix: represented by two uppercase letters in the human readable form, and encoded as three digits in the ean13. Please be aware that some encoded prefixes begin with zero, which can get stripped under some circumstances. Prefixes generally identify the type of item which has received the barcode and are registered in an external database.
- A number: A number between 0 and 9999999 inclusive. The human form is not typically zero padded.
- A checksum: In addition to the ean13 of the machine printed version, barcodes also contain a single character / two digit internal checksum used to identify input errors of the human readable form.
In addition, printed forms will contain the standard EAN checksum digit. This checksum is included in the output of this gem and does not need to be recalculated .
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install sanger_barcode_format
# Using builders barcode = ::.('DN12345R') barcode = ::.(4500101234757) barcode = ::.('EG',123) # Using standard initialize barcode = ::.(prefix:'EG',number:123) barcode = ::.(human_barcode:'DN12345R') barcode = ::.(hmachine_barcode:4500101234757) # Converting between formats barcode = ::.(prefix:'PR',number:1234) barcode.human_barcode # => PR1234K' barcode.machine_barcode # => 4500001234757 # Pulling out components barcode = ::.(machine_barcode: 4500001234757) barcode.prefix.human # => 'PR' barcode.checksum.human # => 'K'
A number of legacy method are provided in the module SBCF::LegacyMethods. These are used to allow near drop-in replacement of the barcode component of Sequencescape. They should NOT be used for new applications. Legacy methods should be required explicitly, and can be used to extend existing interfaces.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request