Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YARD docs to Faker::Bank #1989

Merged
merged 1 commit into from
May 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions lib/faker/default/bank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ class Bank < Base
flexible :bank

class << self
##
# Produces a bank account number.
#
# @param digits [Integer] Number of digits that the generated account number should have.
# @return [String]
#
# @example
# Faker::Bank.account_number #=> 6738582379
# Faker::Bank.account_number(digits: 13) #=> 673858237902
#
# @faker.version 1.9.1
def account_number(legacy_digits = NOT_GIVEN, digits: 10)
warn_for_deprecated_arguments do |keywords|
keywords << :digits if legacy_digits != NOT_GIVEN
Expand All @@ -17,6 +28,17 @@ def account_number(legacy_digits = NOT_GIVEN, digits: 10)
output[0...digits]
end

##
# Produces a bank iban number.
#
# @param country_code [String] Specifies what country prefix is used to generate the iban code.
# @return [String]
#
# @example
# Faker::Bank.iban #=> "GB76DZJM33188515981979"
# Faker::Bank.iban(country_code: "be") #=> "BE6375388567752043"
#
# @faker.version 1.7.0
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
Expand All @@ -38,18 +60,54 @@ def iban(legacy_country_code = NOT_GIVEN, country_code: 'GB')
country_code.upcase + iban_checksum(country_code, account) + account
end

##
# Produces a bank name.
#
# @return [String]
#
# @example
# Faker::Bank.name #=> "ABN AMRO CORPORATE FINANCE LIMITED"
#
# @faker.version 1.7.0
def name
fetch('bank.name')
end

##
# Produces a routing number.
#
# @return [String]
#
# @example
# Faker::Bank.routing_number #=> "729343831"
#
# @faker.version 1.9.1
def routing_number
valid_routing_number
end

##
# Produces a valid routing number.
#
# @return [String]
#
# @example
# Faker::Bank.routing_number #=> "729343831"
#
# @faker.version 1.9.1
def routing_number_with_format
compile_fraction(valid_routing_number)
end

##
# Produces a swift / bic number.
#
# @return [String]
#
# @example
# Faker::Bank.swift_bic #=> "AAFMGB21"
#
# @faker.version 1.7.0
def swift_bic
fetch('bank.swift_bic')
end
Expand Down