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::Driving_Licence #1997

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions lib/faker/default/driving_licence.rb
Expand Up @@ -6,6 +6,23 @@ class DrivingLicence < Base
NI_CHANCE = 0.03 # NI Pop is about 3% of total UK population

class << self
##
# Produces a random British driving licence number.
#
# @param last_name [String] The last name of the driving licence's owner.
# @param initials [String] The initials of the driving licence's owner.
# @param gender [String] The gender of the driving licence's owner.
# @param date_of_birth [String] The date of birth of the driving licence's owner.
# @return [String]
#
# @example
# Faker::DrivingLicence.british_driving_licence #=> "MCDER712081VF7EK"
# Faker::DrivingLicence.british_driving_licence(last_name: "O'Carroll",
# initials: "J",
# gender: :female,
# date_of_birth: Date.parse("1986-10-24")) #=> "OCARR815246J91HT"
#
# @faker.version 1.9.2
# rubocop:disable Metrics/ParameterLists
def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_GIVEN, legacy_gender = NOT_GIVEN, legacy_date_of_birth = NOT_GIVEN, last_name: Faker::Name.last_name, initials: Faker::Name.initials, gender: random_gender, date_of_birth: Faker::Date.birthday(min_age: 18, max_age: 65))
# rubocop:enable Metrics/ParameterLists
Expand All @@ -24,10 +41,33 @@ def british_driving_licence(legacy_last_name = NOT_GIVEN, legacy_initials = NOT_
].join
end

##
# Produces a random Northern Irish licence number.
#
# @return [String]
#
# @example
# Faker::DrivingLicence.northern_irish_driving_licence #=> "70702548"
#
# @faker.version 1.9.2
def northern_irish_driving_licence
Faker::Number.number(digits: 8).to_s
end

##
# Produces a random UK driving licence number in either GB or NI format, at a rate consistent with their relative populations
#
# @param last_name [String] The last name of the driving licence's owner.
# @param initials [String] The initials of the driving licence's owner.
# @param gender [String] The gender of the driving licence's owner.
# @param date_of_birth [String] The date of birth of the driving licence's owner.
# @return [String]
#
# @example
# Faker::DrivingLicence.uk_driving_licence #=> "OCARR815246J91HT"
# Faker::DrivingLicence.uk_driving_licence #=> "70702548"
#
# @faker.version 1.9.2
def uk_driving_licence(*args)
if Faker::Config.random.rand < NI_CHANCE
northern_irish_driving_licence
Expand Down