Module: FFaker::PhoneNumberSN

Extended by:
ModuleUtils, PhoneNumberSN
Included in:
PhoneNumberSN
Defined in:
lib/ffaker/phone_number_sn.rb

Overview

Author: PapePathe<[email protected]> www.xarala.sn

Constant Summary collapse

MobileOperatorsPrefix =

Mobile Operator prefixes

77 =>  Orange
76 =>  Tigo
70 =>  Expresso
%w(70 76 77)
HomeWorkOperatorsPrefix =

Home or Work Operator prefixes

33 =>  Orange
%w(33)

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#homework_numberObject

Generates a home or work phone number Example 33 845 77 99 Example 33 945 07 00 Example 33 906 29 05


60
61
62
# File 'lib/ffaker/phone_number_sn.rb', line 60

def homework_number
  "#{homework_phone_prefix}-#{[8, 9][rand(1)]}#{FFaker.numerify('##-##-##')}"
end

#homework_phone_prefixObject

Return a prefix in HomeWorkOperatorsPrefix


33
34
35
# File 'lib/ffaker/phone_number_sn.rb', line 33

def homework_phone_prefix
  HomeWorkOperatorsPrefix[0]
end

#mobile_numberObject

Generates a mobile phone number Example 70 745 77 99 Example 76 245 07 00 Example 77 726 29 05


51
52
53
# File 'lib/ffaker/phone_number_sn.rb', line 51

def mobile_number
  "#{mobile_phone_prefix}-#{short_phone_number}"
end

#mobile_phone_prefixObject

Return a prefix in MobileOperatorsPrefix


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

def mobile_phone_prefix
  MobileOperatorsPrefix[rand(3)]
end

#phone_numberObject

Generates a random phone number mobile or home or work


66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ffaker/phone_number_sn.rb', line 66

def phone_number
  case rand(10)
  when 0 then homework_number
  when 9 then homework_number
  when 3 then mobile_number
  when 5 then mobile_number
  when 6 then mobile_number
  when 8 then mobile_number
  else        homework_number
  end
end

#short_phone_numberObject

Pattern that can be combined with a prefix to generate mobile, office phone_numbers Example 745 77 99 Example 245 07 00 Example 726 29 05


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

def short_phone_number
  FFaker.numerify('###-##-##')
end