Module: FFaker::PhoneNumberCH

Extended by:
ModuleUtils, PhoneNumberCH
Included in:
PhoneNumberCH
Defined in:
lib/ffaker/phone_number_ch.rb

Constant Summary collapse

COUNTRY_PREFIX =
%w(+41 0041 0)
AREA_PREFIX =
%w(21 22 24 26 27 31 32 33 34 41 43 44 51 52 56 58 61 62 71 81 91)
MOBILE_PREFIX =
%w(74 75 76 77 78 79)
FREE_PHONE_PREFIX =
%w(800)
SHARED_COST_PREFIX =
%w(840 842 844 848)
PREMIUM_RATE_PREFIX =
%w(900 901 906)
PHONE_NUMBER =
['#######', ' ### ## ##']

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#free_phone_numberObject



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

def free_phone_number
  FFaker.numerify "#{COUNTRY_PREFIX.sample}#{FREE_PHONE_PREFIX.sample}#{PHONE_NUMBER.sample}"
end

#home_work_phone_numberObject



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

def home_work_phone_number
  FFaker.numerify "#{COUNTRY_PREFIX.sample}#{AREA_PREFIX.sample}#{PHONE_NUMBER.sample}"
end

#mobile_phone_numberObject



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

def mobile_phone_number
  FFaker.numerify "#{COUNTRY_PREFIX.sample}#{MOBILE_PREFIX.sample}#{PHONE_NUMBER.sample}"
end

#phone_numberObject



16
17
18
19
20
21
22
23
24
# File 'lib/ffaker/phone_number_ch.rb', line 16

def phone_number
  case rand(5)
  when 0 then home_work_phone_number
  when 1 then mobile_phone_number
  when 2 then free_phone_number
  when 3 then shared_cost_phone_number
  when 4 then premium_rate_phone_number
  end
end

#premium_rate_phone_numberObject



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

def premium_rate_phone_number
  FFaker.numerify "#{COUNTRY_PREFIX.sample}#{PREMIUM_RATE_PREFIX.sample}#{PHONE_NUMBER.sample}"
end

#shared_cost_phone_numberObject



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

def shared_cost_phone_number
  FFaker.numerify "#{COUNTRY_PREFIX.sample}#{SHARED_COST_PREFIX.sample}#{PHONE_NUMBER.sample}"
end