module FFaker::Bank

Constants

COUNTRIES

Public Instance Methods

card_expiry_date(year_range: 5, year_latest: -5, format: '%m/%y') click to toggle source
# File lib/ffaker/bank.rb, line 98
def card_expiry_date(year_range: 5, year_latest: -5, format: '%m/%y')
  FFaker::Time.date({ year_range: year_range, year_latest: year_latest }).strftime(format)
end
card_number() click to toggle source
# File lib/ffaker/bank.rb, line 94
def card_number
  FFaker.numerify('#### #### #### ####')
end
card_type() click to toggle source
# File lib/ffaker/bank.rb, line 102
def card_type
  fetch_sample(CARD_TYPES)
end
iban(country_code: nil) click to toggle source
# File lib/ffaker/bank.rb, line 87
def iban(country_code: nil)
  return formatify_iban(fetch_sample(COUNTRIES.values)) unless country_code

  check_country_existence(country_code)
  formatify_iban(COUNTRIES[country_code.upcase])
end

Private Instance Methods

check_country_existence(country_code) click to toggle source
# File lib/ffaker/bank.rb, line 112
def check_country_existence(country_code)
  return if COUNTRIES.key?(country_code.upcase)

  raise ArgumentError, "Unexpected country code: '#{country_code}'"
end
formatify_iban(code) click to toggle source
# File lib/ffaker/bank.rb, line 108
def formatify_iban(code)
  FFaker.bothify(code).upcase
end