Module: FFaker::PhoneNumberAU

Extended by:
ModuleUtils, PhoneNumberAU
Included in:
PhoneNumberAU
Defined in:
lib/ffaker/phone_number_au.rb

Overview

Author: wiseleyb<[email protected]> Based on information from en.wikipedia.org/wiki/Telephone_numbers_in_Australia

Constant Summary collapse

MobileOperatorsPrefix =

Mobile prefixes

%w(04)
HomeWorkOperatorsPrefix =

Home or Work Operator prefixes

%w(02 03 05 07 08)
OperatorsPrefix =
MobileOperatorsPrefix + HomeWorkOperatorsPrefix

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#country_codeObject


58
59
60
# File 'lib/ffaker/phone_number_au.rb', line 58

def country_code
  '+61'
end

#home_work_phone_numberObject

Generates a general phone number

(0x) xxxx xxxx

39
40
41
# File 'lib/ffaker/phone_number_au.rb', line 39

def home_work_phone_number
  FFaker.numerify("(#{home_work_phone_prefix}) #### ####")
end

#home_work_phone_prefixObject

Return a prefix in HomeWorkOperatorsPrefix


28
29
30
# File 'lib/ffaker/phone_number_au.rb', line 28

def home_work_phone_prefix
  HomeWorkOperatorsPrefix[rand(HomeWorkOperatorsPrefix.size)]
end

#international_home_work_phone_numberObject


66
67
68
# File 'lib/ffaker/phone_number_au.rb', line 66

def international_home_work_phone_number
  FFaker.numerify("#{country_code} #{home_work_phone_prefix[1]} #### ####")
end

#international_mobile_phone_numberObject


62
63
64
# File 'lib/ffaker/phone_number_au.rb', line 62

def international_mobile_phone_number
  FFaker.numerify("#{country_code} #{mobile_phone_prefix[1]} #### ####")
end

#international_phone_numberObject


70
71
72
73
74
75
# File 'lib/ffaker/phone_number_au.rb', line 70

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

#mobile_phone_numberObject

Generates a mobile phone number 04xx xxx xxx


46
47
48
# File 'lib/ffaker/phone_number_au.rb', line 46

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

#mobile_phone_prefixObject

Return a prefix in MobileOperatorsPrefix


21
22
23
# File 'lib/ffaker/phone_number_au.rb', line 21

def mobile_phone_prefix
  MobileOperatorsPrefix[rand(MobileOperatorsPrefix.size)]
end

#phone_numberObject

generates mobile or home/work number


51
52
53
54
55
56
# File 'lib/ffaker/phone_number_au.rb', line 51

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

#phone_prefixObject


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

def phone_prefix
  OperatorsPrefix[rand(OperatorsPrefix.size)]
end