Class: Faker::DrivingLicence

Inherits:
Base
  • Object
show all
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::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, 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(18, 65)) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/faker/default/driving_licence.rb', line 9

def british_driving_licence(last_name: Faker::Name.last_name,
                            initials: Faker::Name.initials,
                            gender: random_gender,
                            date_of_birth: Faker::Date.birthday(18, 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_licenceObject



21
22
23
# File 'lib/faker/default/driving_licence.rb', line 21

def northern_irish_driving_licence
  Faker::Number.number(8)
end

.uk_driving_licence(*args) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/faker/default/driving_licence.rb', line 25

def uk_driving_licence(*args)
  if Faker::Config.random.rand < NI_CHANCE
    northern_irish_driving_licence
  else
    british_driving_licence(*args)
  end
end