Sha256: 16f791f4eb80c57c5e593e5cccc23358e6d7bb6e0bee449d542f517e9be9cde0
Contents?: true
Size: 464 Bytes
Versions: 3
Compression:
Stored size: 464 Bytes
Contents
require "jan/parser" require "jan/check_digit_calculator" class Jan < ::String module Random module_function Digits = %w(1 2 3 4 5 6 7 8 9 0) def code(size=13) build(size) end def instore_code(size=13) build(size - 2, InstoreCodePrefixes.sample) end def build(size, code="") size.times{ code += Digits.sample } Parser.body(code) + CheckDigitCalculator.calculate(Parser.body(code)).to_s end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jan-0.1.0 | lib/jan/random.rb |
jan-0.0.5 | lib/jan/random.rb |
jan-0.0.4 | lib/jan/random.rb |