Class: Faker::DrivingLicence
- Defined in:
- lib/faker/default/driving_licence.rb
Constant Summary collapse
- GB_PADDING =
'9999'
- NI_CHANCE =
NI Pop is about 3% of total UK population
0.03
Constants inherited from Base
Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.british_driving_licence(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)) ⇒ String
Produces a random British driving licence number.
-
.northern_irish_driving_licence ⇒ String
Produces a random Northern Irish licence number.
-
.uk_driving_licence(*args) ⇒ String
Produces a random UK driving licence number in either GB or NI format, at a rate consistent with their relative populations.
-
.usa_driving_licence(state = 'California') ⇒ String
Produces a random USA driving licence number by state code passed.
Methods inherited from Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale
Class Method Details
.british_driving_licence(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)) ⇒ String
Produces a random British driving licence number.
26 27 28 29 30 31 32 33 |
# File 'lib/faker/default/driving_licence.rb', line 26 def british_driving_licence(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)) [ gb_licence_padding(last_name, 5), gb_licence_year(date_of_birth, gender), gb_licence_padding(initials, 2), gb_licence_checksum ].join end |
.northern_irish_driving_licence ⇒ String
Produces a random Northern Irish licence number.
44 45 46 |
# File 'lib/faker/default/driving_licence.rb', line 44 def northern_irish_driving_licence Faker::Number.number(digits: 8).to_s end |
.uk_driving_licence(last_name, initials, gender, date_of_birth) ⇒ String .uk_driving_licence ⇒ String
Produces a random UK driving licence number in either GB or NI format, at a rate consistent with their relative populations
64 65 66 67 68 69 70 |
# File 'lib/faker/default/driving_licence.rb', line 64 def uk_driving_licence(*args) if Faker::Config.random.rand < NI_CHANCE northern_irish_driving_licence else british_driving_licence(*args) end end |
.usa_driving_licence(state = 'California') ⇒ String
Produces a random USA driving licence number by state code passed.
83 84 85 86 87 |
# File 'lib/faker/default/driving_licence.rb', line 83 def usa_driving_licence(state = 'California') bothify(fetch("driving_licence.usa.#{state.to_s.strip.downcase.gsub(' ', '_')}")) rescue I18n::MissingTranslationData => _e raise InvalidStatePassed, "Invalid state code passed for USA, '#{state}'" end |