class Faker::Bank

Public Class Methods

iban(country_code = "GB") click to toggle source
# File lib/faker/bank.rb, line 14
def iban(country_code = "GB")
  [
    country_code.upcase,
    Array.new(2) { rand(10) },
    iban_range(country_code, :letter_code) { (65 + rand(26)).chr },
    iban_range(country_code, :digits) { rand(10) }
  ].join
end
name() click to toggle source
# File lib/faker/bank.rb, line 6
def name
  fetch('bank.name')
end
swift_bic() click to toggle source
# File lib/faker/bank.rb, line 10
def swift_bic
  fetch('bank.swift_bic')
end

Private Class Methods

iban_length(country_code, number_type) click to toggle source
# File lib/faker/bank.rb, line 30
def iban_length(country_code, number_type)
  fetch("bank.iban_details.#{country_code.downcase}.#{number_type}").to_i
rescue I18n::MissingTranslationData
  raise ArgumentError, "Could not find iban details for #{country_code}"
end
iban_range(country_code, number_type) { || ... } click to toggle source
# File lib/faker/bank.rb, line 25
def iban_range(country_code, number_type)
  array_length = iban_length(country_code, number_type)
  Array.new(array_length) { yield }
end