Sha256: 33b66f9ad459135778dcfdceb28ab9e2f7453744a1631554a50d67716ca15395
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true module FFakerTW # Source: https://en.wikipedia.org/wiki/Telephone_numbers_in_France module PhoneNumberFR extend ModuleUtils extend self COUNTRY_CODE = '33' AREA_PREFIX = %w[01 02 03 04 05].freeze NON_AREA_PREFIX = %w[09].freeze HOME_WORK_PHONE_PREFIX = AREA_PREFIX + NON_AREA_PREFIX MOBILE_PHONE_PREFIX = %w[06 07].freeze PHONE_PREFIX = HOME_WORK_PHONE_PREFIX + MOBILE_PHONE_PREFIX PHONE_NUMBER = ['########', ' ## ## ## ##'].freeze def home_work_phone_number number HOME_WORK_PHONE_PREFIX end def mobile_phone_number number MOBILE_PHONE_PREFIX end # generates mobile or home/work number def phone_number rand(0..1).zero? ? home_work_phone_number : mobile_phone_number end def country_code "#{fetch_sample(['+', '00'])}#{COUNTRY_CODE}" end def international_mobile_phone_number number MOBILE_PHONE_PREFIX, country_code end def international_home_work_phone_number number HOME_WORK_PHONE_PREFIX, country_code end def international_phone_number rand(0..1).zero? ? international_mobile_phone_number : international_home_work_phone_number end private def number(prefixes, country_prefix = '') space = random_space prefix = fetch_sample(prefixes) prefix = prefix[1] unless country_prefix == '' FFakerTW.numerify [ country_prefix, space, prefix, fetch_sample(PHONE_NUMBER) ].join.strip end def random_space rand(0..1).zero? ? '' : ' ' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffakerTW-0.1.0 | lib/ffakerTW/phone_number_fr.rb |