Skip to content

Commit

Permalink
Fix TestFakerCompany::luhn_checksum.
Browse files Browse the repository at this point in the history
  • Loading branch information
01max committed Sep 4, 2018
1 parent 1995c87 commit 0e8d10c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/test_faker_company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ def abn_checksum(abn)
end

def luhn_checksum(luhn)
luhn.each_char.map(&:to_i).reverse.each_with_index.map do |n, i|
luhn_split = luhn.each_char.map(&:to_i).reverse.each_with_index.map do |n, i|
x = i.odd? ? n * 2 : n
x > 9 ? x - 9 : x
end.compact.sum
end

luhn_split.compact.inject(0) { |sum, x| sum + x }
end
end

0 comments on commit 0e8d10c

Please sign in to comment.