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, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#country_codeObject


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

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

#home_work_phone_numberObject


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

def home_work_phone_number
  number HOME_WORK_PHONE_PREFIX
end

#international_home_work_phone_numberObject


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

def international_home_work_phone_number
  number HOME_WORK_PHONE_PREFIX, country_code
end

#international_mobile_phone_numberObject


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

def international_mobile_phone_number
  number MOBILE_PHONE_PREFIX, country_code
end

#international_phone_numberObject


46
47
48
49
50
51
# File 'lib/ffaker/phone_number_fr.rb', line 46

def international_phone_number
  case rand(0..1)
  when 0 then international_mobile_phone_number
  when 1 then international_home_work_phone_number
  end
end

#mobile_phone_numberObject


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

def mobile_phone_number
  number MOBILE_PHONE_PREFIX
end

#phone_numberObject

generates mobile or home/work number


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

def phone_number
  case rand(0..1)
  when 0 then home_work_phone_number
  when 1 then mobile_phone_number
  end
end