Class: Faker::Bank

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/bank.rb

Constant Summary

Constants inherited from Base

Faker::Base::Letters, Faker::Base::Numbers, Faker::Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale

Class Method Details

.iban(bank_country_code = "GB") ⇒ Object

Raises:

  • (ArgumentError)


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

def iban(bank_country_code="GB")
  details = iban_details.find { |country| country["bank_country_code"] == bank_country_code.upcase }
  raise ArgumentError, "Could not find iban details for #{bank_country_code}" unless details
  bcc = details["bank_country_code"] + 2.times.map{ rand(10) }.join
  ilc = (0...details["iban_letter_code"].to_i).map{ (65 + rand(26)).chr }.join
  ib  = details["iban_digits"].to_i.times.map{ rand(10) }.join
  bcc + ilc + ib
end

.nameObject



6
7
8
# File 'lib/faker/bank.rb', line 6

def name
  fetch('bank.name')
end

.swift_bicObject



10
11
12
# File 'lib/faker/bank.rb', line 10

def swift_bic
  fetch('bank.swift_bic')
end