EAN UPC Support

EAN/UPC/GTIN calculations for Ruby

To install the Ruby Gem

sudo gem install ean

What can it do?

– Validate UPC/EAN/GTIN identifiers

– Generate check number for UPC/EAN/GTIN identifiers

How to use

Load the gem:

require "rubygems"
require "ean"

Convert to a 14 digit GTIN:
"1234567890128".to_gtin

Check whether a number is a valid 8, 12, 13, 14 EAN/UPC/GTIN number

"1-234567-890128".ean?

You can also do

"1234567890128".to_gtin.ean?

Given a 7, 11, 12, of 13 digits number, generates the check digit (to be added at the end.

"784794001602".generate_check_digit