Class: Faker::Bank
Constant Summary
Constants inherited from Base
Faker::Base::LLetters, Faker::Base::Letters, Faker::Base::NOT_GIVEN, Faker::Base::Numbers, Faker::Base::ULetters
Class Method Summary collapse
-
.account_number(digits: 10) ⇒ String
Produces a bank account number.
-
.bsb_number ⇒ String
Produces an Australian BSB (Bank-State-Branch) number.
-
.iban(country_code: 'GB') ⇒ String
Produces a bank iban number.
-
.iban_country_code ⇒ String
Produces the ISO 3166 code of a country that uses the IBAN system.
-
.name ⇒ String
Produces a bank name.
-
.routing_number ⇒ String
Produces a routing number.
-
.routing_number_with_format ⇒ String
Produces a valid routing number.
-
.swift_bic ⇒ String
Produces a swift / bic number.
Methods inherited from Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale
Class Method Details
.account_number(digits: 10) ⇒ String
Produces a bank account number.
19 20 21 |
# File 'lib/faker/default/bank.rb', line 19 def account_number(digits: 10) Array.new(digits) { rand(10) }.join end |
.bsb_number ⇒ String
Produces an Australian BSB (Bank-State-Branch) number
129 130 131 |
# File 'lib/faker/default/bank.rb', line 129 def bsb_number compile_bsb_number end |
.iban(country_code: 'GB') ⇒ String
Produces a bank iban number.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/faker/default/bank.rb', line 35 def iban(country_code: 'GB') # Each country has its own format for bank accounts # Many of them use letters in certain parts of the account # Using regex patterns we can create virtually any type of bank account country_code ||= iban_country_code begin pattern = fetch("bank.iban_details.#{country_code.downcase}.bban_pattern") rescue I18n::MissingTranslationData raise ArgumentError, "Could not find iban details for #{country_code}" end # Use Faker::Base.regexify for creating a sample from bank account format regex account = Base.regexify(/#{pattern}/) # Add country code and checksum to the generated account to form valid IBAN country_code.upcase + iban_checksum(country_code, account) + account end |
.iban_country_code ⇒ String
Produces the ISO 3166 code of a country that uses the IBAN system.
63 64 65 |
# File 'lib/faker/default/bank.rb', line 63 def iban_country_code sample(translate('faker.bank.iban_details').keys).to_s.upcase end |
.name ⇒ String
Produces a bank name.
76 77 78 |
# File 'lib/faker/default/bank.rb', line 76 def name fetch('bank.name') end |
.routing_number ⇒ String
Produces a routing number.
89 90 91 |
# File 'lib/faker/default/bank.rb', line 89 def routing_number valid_routing_number end |
.routing_number_with_format ⇒ String
Produces a valid routing number.
102 103 104 |
# File 'lib/faker/default/bank.rb', line 102 def routing_number_with_format compile_fraction(valid_routing_number) end |
.swift_bic ⇒ String
Produces a swift / bic number.
115 116 117 |
# File 'lib/faker/default/bank.rb', line 115 def swift_bic fetch('bank.swift_bic') end |