lib/luhn.rb in moeffju-luhn-0.1.1 vs lib/luhn.rb in moeffju-luhn-0.1.2
- old
+ new
@@ -1,7 +1,7 @@
require "luhn/version"
-class Fixnum
+class Numeric
def luhn
digits = self.to_s.chars.map(&:to_i)
sum = digits.reverse.each_with_index.map{ |x, i| i.even? ? (x * 2).divmod(10).inject(:+) : x }.reverse.inject(:+)
(10 - sum % 10)
end