Giter Club home page Giter Club logo

barkick's Introduction

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

barkick's People

Contributors

ankane avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.