Module: FFaker::PhoneNumberTW

Extended by:
ModuleUtils, PhoneNumberTW
Included in:
PhoneNumberTW
Defined in:
lib/ffaker/phone_number_tw.rb

Constant Summary collapse

HOME_PHONE_PREFIXES =
%w[02 03 04 05 06 07 08].freeze
MOBILE_PHONE_PREFIX =
'09'

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

#contry_codeObject



29
30
31
# File 'lib/ffaker/phone_number_tw.rb', line 29

def contry_code
  '+886'
end

#home_work_phone_numberObject



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

def home_work_phone_number
  prefix = fetch_sample(HOME_PHONE_PREFIXES)
  case prefix
  when '02', '04'
    FFaker.numerify("(#{prefix}) ####-####")
  else
    FFaker.numerify("(#{prefix}) ###-####")
  end
end

#international_home_work_phone_numberObject



39
40
41
42
43
# File 'lib/ffaker/phone_number_tw.rb', line 39

def international_home_work_phone_number
  number = home_work_phone_number
  number[0..4] = "#{contry_code}-#{number[2]}-"
  number
end

#international_mobile_phone_numberObject



33
34
35
36
37
# File 'lib/ffaker/phone_number_tw.rb', line 33

def international_mobile_phone_number
  number = mobile_phone_number
  number[0] = "#{contry_code}-"
  number
end

#international_phone_numberObject



45
46
47
# File 'lib/ffaker/phone_number_tw.rb', line 45

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

#mobile_phone_numberObject



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

def mobile_phone_number
  FFaker.numerify("#{MOBILE_PHONE_PREFIX}##-###-###")
end

#phone_numberObject



11
12
13
# File 'lib/ffaker/phone_number_tw.rb', line 11

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