Skip to content

s-osa/jan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jan

Gem Version Build Status

jan is a small utility gem for JAN code.

Supported versions

  • Ruby
    • 2.7.x
    • 2.6.x
    • 2.5.x

Installation

Add this line to your application's Gemfile:

gem 'jan'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jan

Usage

Basic

code = Jan::Code.new('4901277241126')

code.valid? # => true

code.body # => '490127724112'
code.check_digit # => '6'

code.source_marking? # => true
code.instore_marking? # => false

Calculate check digit

body = Jan::CodeBody.new('490127724112')

body.calculate_check_digit # => '6'
body.generate_code # => '4901277241126'

Generate random code

random = Jan::Random.new

random.code # => '5689450935688'
random.instore_code # => '2799375754394'

Contributing

Bug reports and pull requests are welcome.

  • Install dependencies
    • bundle install
  • Run tests
    • rake spec