Module: FFaker::PhoneNumberBR
Overview
Constant Summary
collapse
- COUNTRY_PREFIX =
'+55'
- AREA_CODE =
[
11..19, 21..22, 24, 27..28, 31..35, 37..38, 41..49,
51, 53..55, 61..69, 71, 73..75, 77, 79, 81..89, 91..99
].flat_map { |x| Array(x) }.map(&:to_s).freeze
- HOME_WORK_PHONE_PREFIX =
%w[2 3 4 5].freeze
- MOBILE_PHONE_PREFIX =
%w[96 97 98 99].freeze
- PHONE_NUMBER =
%w[####### ###-####].freeze
Instance Method Summary
collapse
const_missing, k, luhn_check, underscore, unique
#fetch_sample, #rand, #shuffle
Instance Method Details
#country_code ⇒ Object
53
54
55
|
# File 'lib/ffaker/phone_number_br.rb', line 53
def country_code
COUNTRY_PREFIX
end
|
#home_work_phone_number ⇒ Object
31
32
33
|
# File 'lib/ffaker/phone_number_br.rb', line 31
def home_work_phone_number
number HOME_WORK_PHONE_PREFIX
end
|
#international_home_work_phone_number ⇒ Object
#international_mobile_phone_number ⇒ Object
#international_phone_number ⇒ Object
pick a random phone number with the international prefix code
41
42
43
|
# File 'lib/ffaker/phone_number_br.rb', line 41
def international_phone_number
rand(0..1).zero? ? international_mobile_phone_number : international_home_work_phone_number
end
|
#mobile_phone_number ⇒ Object
35
36
37
|
# File 'lib/ffaker/phone_number_br.rb', line 35
def mobile_phone_number
number MOBILE_PHONE_PREFIX
end
|
#phone_number ⇒ Object
generate a random phone number
27
28
29
|
# File 'lib/ffaker/phone_number_br.rb', line 27
def phone_number
rand(0..1).zero? ? home_work_phone_number : mobile_phone_number
end
|