All Projects → ankane → Barkick

ankane / Barkick

Licence: mit
Barcodes made easy

Programming Languages

ruby
36898 projects - #4 most used programming language

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

Upgrading

0.1.0

There a few breaking changes to be aware of:

  • GTIN is now Barkick::GTIN
  • 8-digit codes now raise an ArgumentError if type is not specified

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].