/barkick

Barcodes made easy

Primary LanguageRubyMIT LicenseMIT

Barkick

Barcodes made easy

Works with:

For PLU codes, check out the plu gem

Build Status

Installation

Add this line to your Gemfile:

gem "barkick"

How To Use

gtin = Barkick::GTIN.new("016000275263")
gtin.valid?       # true
gtin.gtin14       # "00016000275263"
gtin.ean13        # "0016000275263"
gtin.upc          # "016000275263"
gtin.prefix       # "001"
gtin.prefix_name  # "GS1 US"
gtin.country_code # "US"

Variable items

gtin = Barkick::GTIN.new("299265108631")
gtin.variable?   # true
gtin.restricted? # true
gtin.price       # 8.63
gtin.base_gtin14 # "00299265000003"

UPC-E

gtin = Barkick::GTIN.new("03744806", type: :upc_e)
gtin.base_gtin14 # "00037000004486"

EAN-8

gtin = Barkick::GTIN.new("01234565", type: :ean8)
gtin.base_gtin14 # "00000001234565"

Calculate check digit

Barkick::GTIN.check_digit("01600027526") # "3"

For UPC-E, convert to UPC-A before passing to this method

Resources

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/barkick.git
cd barkick
bundle install
bundle exec rake test