Module: FFaker::BankUS

Extended by:
BankUS, ModuleUtils
Included in:
BankUS
Defined in:
lib/ffaker/bank_us.rb

Constant Summary collapse

ROUTING_NUMBER_PREFIXES =
[*'00'..'12', *'21'..'32', *'61'..'72', '80'].freeze

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#account_number(min_digits: 9, max_digits: 17) ⇒ Object



10
11
12
# File 'lib/ffaker/bank_us.rb', line 10

def (min_digits: 9, max_digits: 17)
  FFaker.numerify('#' * rand(min_digits..max_digits))
end

#routing_numberObject



14
15
16
17
18
19
20
21
# File 'lib/ffaker/bank_us.rb', line 14

def routing_number
  first_two_digits = fetch_sample(ROUTING_NUMBER_PREFIXES)

  partial_routing_number = FFaker.numerify("#{first_two_digits}######")
  ninth_digit = generate_ninth_digit(partial_routing_number)

  "#{partial_routing_number}#{ninth_digit}"
end