class RussianPost::Barcode::Domestic
Public Class Methods
format()
click to toggle source
# File lib/russianpost/barcode/domestic.rb, line 6 def self.format /\A\d{14}\Z/ end
Private Instance Methods
checkdigit()
click to toggle source
# File lib/russianpost/barcode/domestic.rb, line 12 def checkdigit odds, evens = *digits.partition.with_index { |d, i| (i&1).zero? } (10 - ((odds.reduce(:+) * 3 + evens[0..-2].reduce(:+)) % 10)) % 10 end