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(legacy_digits = NOT_GIVEN, digits: 10) ⇒ String
Produces a bank account number.
-
.bsb_number ⇒ String
Produces an Australian BSB (Bank-State-Branch) number.
-
.iban(legacy_country_code = NOT_GIVEN, country_code: 'GB') ⇒ String
Produces a bank iban number.
-
.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, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.account_number(legacy_digits = NOT_GIVEN, digits: 10) ⇒ String
Produces a bank account number.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/faker/default/bank.rb', line 19 def account_number(legacy_digits = NOT_GIVEN, digits: 10) warn_for_deprecated_arguments do |keywords| keywords << :digits if legacy_digits != NOT_GIVEN end output = '' output += rand.to_s[2..-1] while output.length < digits output[0...digits] end |
.bsb_number ⇒ String
Produces an Australian BSB (Bank-State-Branch) number
125 126 127 |
# File 'lib/faker/default/bank.rb', line 125 def bsb_number compile_bsb_number end |
.iban(legacy_country_code = NOT_GIVEN, country_code: 'GB') ⇒ String
Produces a bank iban number.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/faker/default/bank.rb', line 42 def iban(legacy_country_code = NOT_GIVEN, 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 warn_for_deprecated_arguments do |keywords| keywords << :country_code if legacy_country_code != NOT_GIVEN end 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 |
.name ⇒ String
Produces a bank name.
72 73 74 |
# File 'lib/faker/default/bank.rb', line 72 def name fetch('bank.name') end |
.routing_number ⇒ String
Produces a routing number.
85 86 87 |
# File 'lib/faker/default/bank.rb', line 85 def routing_number valid_routing_number end |
.routing_number_with_format ⇒ String
Produces a valid routing number.
98 99 100 |
# File 'lib/faker/default/bank.rb', line 98 def routing_number_with_format compile_fraction(valid_routing_number) end |
.swift_bic ⇒ String
Produces a swift / bic number.
111 112 113 |
# File 'lib/faker/default/bank.rb', line 111 def swift_bic fetch('bank.swift_bic') end |