class Ibandit::GermanDetailsConverter::Rule002002::Check63
Public Class Methods
Source
# File lib/ibandit/german_details_converter.rb, line 539 def initialize(account_number) @account_number = account_number.dup.rjust(10, "0") end
A Deutsche Bank specific variant of Check 63
Public Instance Methods
Source
# File lib/ibandit/german_details_converter.rb, line 543 def valid? expected_check_digit = (10 - remainder) % 10 expected_check_digit == @account_number[-3].to_i end
Private Instance Methods
Source
# File lib/ibandit/german_details_converter.rb, line 550 def remainder sum_of_weighted_digits % 10 end
Source
# File lib/ibandit/german_details_converter.rb, line 554 def sum_of_weighted_digits weighted_digits.sum end
Source
# File lib/ibandit/german_details_converter.rb, line 558 def weighted_digits weighted_values.flat_map { |value| value.to_s.chars.map(&:to_i) } end
Source
# File lib/ibandit/german_details_converter.rb, line 562 def weighted_values weights = [2, 1, 2, 1, 2, 1] @account_number.slice(1, 6).reverse.chars.map.with_index do |digit, i| digit.to_i * weights[i] end end