Module: FFaker::PhoneNumberBR

Extended by:
ModuleUtils, PhoneNumberBR
Included in:
PhoneNumberBR
Defined in:
lib/ffaker/phone_number_br.rb

Overview

Constant Summary collapse

COUNTRY_PREFIX =
'+55'
AREA_CODE =
%w(1# 2# 3# 4# 5# 6# 7# 8# 9#)
HOME_WORK_PHONE_PREFIX =
%w(2 3 4 5)
MOBILE_PHONE_PREFIX =
%w(6 7 8 9 96 97 98 99)
PHONE_NUMBER =
%w(####### ###-####)

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#country_codeObject


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

def country_code
  COUNTRY_PREFIX
end

#home_work_phone_numberObject


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

def home_work_phone_number
  number HOME_WORK_PHONE_PREFIX
end

#international_home_work_phone_numberObject


47
48
49
# File 'lib/ffaker/phone_number_br.rb', line 47

def international_home_work_phone_number
  number HOME_WORK_PHONE_PREFIX, COUNTRY_PREFIX
end

#international_mobile_phone_numberObject


43
44
45
# File 'lib/ffaker/phone_number_br.rb', line 43

def international_mobile_phone_number
  number MOBILE_PHONE_PREFIX, COUNTRY_PREFIX
end

#international_phone_numberObject

pick a random phone number with the international prefix code


36
37
38
39
40
41
# File 'lib/ffaker/phone_number_br.rb', line 36

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


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

def mobile_phone_number
  number MOBILE_PHONE_PREFIX
end

#phone_numberObject

generate a random phone number


19
20
21
22
23
24
# File 'lib/ffaker/phone_number_br.rb', line 19

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