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 =
[
  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

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#country_codeObject



53
54
55
# File 'lib/ffaker/phone_number_br.rb', line 53

def country_code
  COUNTRY_PREFIX
end

#home_work_phone_numberObject



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_numberObject



49
50
51
# File 'lib/ffaker/phone_number_br.rb', line 49

def international_home_work_phone_number
  number HOME_WORK_PHONE_PREFIX, COUNTRY_PREFIX
end

#international_mobile_phone_numberObject



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

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



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_numberObject



35
36
37
# File 'lib/ffaker/phone_number_br.rb', line 35

def mobile_phone_number
  number MOBILE_PHONE_PREFIX
end

#phone_numberObject

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