Module: FFaker::PhoneNumberFR

Extended by:
ModuleUtils, PhoneNumberFR
Included in:
PhoneNumberFR
Defined in:
lib/ffaker/phone_number_fr.rb

Overview

Constant Summary collapse

COUNTRY_CODE =
'33'
AREA_PREFIX =
%w[01 02 03 04 05].freeze
NON_AREA_PREFIX =
%w[09].freeze
HOME_WORK_PHONE_PREFIX =
AREA_PREFIX + NON_AREA_PREFIX
MOBILE_PHONE_PREFIX =
%w[06 07].freeze
PHONE_PREFIX =
HOME_WORK_PHONE_PREFIX + MOBILE_PHONE_PREFIX
PHONE_NUMBER =
['########', ' ## ## ## ##'].freeze

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#country_codeObject



30
31
32
# File 'lib/ffaker/phone_number_fr.rb', line 30

def country_code
  "#{fetch_sample(['+', '00'])}#{COUNTRY_CODE}"
end

#home_work_phone_numberObject



17
18
19
# File 'lib/ffaker/phone_number_fr.rb', line 17

def home_work_phone_number
  number HOME_WORK_PHONE_PREFIX
end

#international_home_work_phone_numberObject



38
39
40
# File 'lib/ffaker/phone_number_fr.rb', line 38

def international_home_work_phone_number
  number HOME_WORK_PHONE_PREFIX, country_code
end

#international_mobile_phone_numberObject



34
35
36
# File 'lib/ffaker/phone_number_fr.rb', line 34

def international_mobile_phone_number
  number MOBILE_PHONE_PREFIX, country_code
end

#international_phone_numberObject



42
43
44
# File 'lib/ffaker/phone_number_fr.rb', line 42

def international_phone_number
  rand(0..1).zero? ? international_mobile_phone_number : international_home_work_phone_number
end

#mobile_phone_numberObject



21
22
23
# File 'lib/ffaker/phone_number_fr.rb', line 21

def mobile_phone_number
  number MOBILE_PHONE_PREFIX
end

#phone_numberObject

generates mobile or home/work number



26
27
28
# File 'lib/ffaker/phone_number_fr.rb', line 26

def phone_number
  rand(0..1).zero? ? home_work_phone_number : mobile_phone_number
end