Skip to content
/ jan Public
forked from s-osa/jan

JAN object gem

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

kamiya54/jan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jan

Build Status

A small utility for JAN code.

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 usage

jan = Jan.new("4901277241126")
jan.valid? # => true

Jan::Validator.validate("4901277241126") # => true

Calculate check digit

# Correct code: "4901277241126"

Jan::CheckDigitCalculator.calculate("490127724112") # => 6

Get elements

jan = Jan.new("4901277241126")
jan.check_digit # => 6
jan.body # => "490127724112"

Jan::Parser.check_digit("4901277241126") # => 6
Jan::Parser.body("4901277241126") # => "490127724112"

Distinct in-store code

jan = Jan.new("4901277241126")
jan.instore_code? # => false

Jan::Paser.instore_code?("2163179230340") # => true

Generate random code

Jan::Random.code # => "5689450935688"
Jan::Random.code(8) # => "11774853"

Jan::Random.instore_code # => "2799375754394"
Jan::Random.instore_code(8) # => "27393086"

Contributing

  1. Fork it ( https://github.com/[my-github-username]/jan/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

JAN object gem

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published