Module: FFaker::PhoneNumberSN

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

Constant Summary collapse

MOBILE_OPERATORS_PREFIX =

Mobile Operator prefixes

77 =>  Orange
76 =>  Tigo
70 =>  Expresso
%w[70 76 77].freeze
HOME_WORK_OPERATORS_PREFIX =

Home or Work Operator prefixes

33 =>  Orange
%w[33].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

#homework_numberObject

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


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

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

#homework_phone_prefixObject

Return a prefix in HOME_WORK_OPERATORS_PREFIX


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

def homework_phone_prefix
  fetch_sample(HOME_WORK_OPERATORS_PREFIX)
end

#mobile_numberObject

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


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

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

#mobile_phone_prefixObject

Return a prefix in MOBILE_OPERATORS_PREFIX


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

def mobile_phone_prefix
  fetch_sample(MOBILE_OPERATORS_PREFIX)
end

#phone_numberObject

Generates a random phone number mobile or home or work


65
66
67
68
69
# File 'lib/ffaker/phone_number_sn.rb', line 65

def phone_number
  return homework_number if rand(0..1).zero?

  mobile_number
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


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

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