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'.freeze
AREA_CODE =
[
  10..19, 21..22, 24, 27..28, 31..35, 37..38, 41..49,
  51..54, 55, 61..69, 71..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, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#country_codeObject


61
62
63
# File 'lib/ffaker/phone_number_br.rb', line 61

def country_code
  COUNTRY_PREFIX
end

#home_work_phone_numberObject


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

def home_work_phone_number
  number HOME_WORK_PHONE_PREFIX
end

#international_home_work_phone_numberObject


57
58
59
# File 'lib/ffaker/phone_number_br.rb', line 57

def international_home_work_phone_number
  number HOME_WORK_PHONE_PREFIX, COUNTRY_PREFIX
end

#international_mobile_phone_numberObject


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

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


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

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

#mobile_phone_numberObject


40
41
42
# File 'lib/ffaker/phone_number_br.rb', line 40

def mobile_phone_number
  number MOBILE_PHONE_PREFIX
end

#phone_numberObject

generate a random phone number


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

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