Sha256: 9cbc265d54e3cbaceb5dc1342bbc58ac088d388094a45f18f16d0ee2b9e05052
Contents?: true
Size: 303 Bytes
Versions: 1
Compression:
Stored size: 303 Bytes
Contents
module Credy class Check def self.luhn(code) s1 = s2 = 0 code.to_s.reverse.chars.each_slice(2) do |odd, even| s1 += odd.to_i double = even.to_i * 2 double -= 9 if double >= 10 s2 += double end (s1 + s2) % 10 == 0 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
credy-0.1.1 | lib/credy/check.rb |