Sha256: c2b4d084e7a1c3e086b13f5a2bff2a731c01938b3fb246465f134de422284f4b

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

# encoding: utf-8

module Faker
  module PhoneNumberIT
    extend ModuleUtils
    extend self

    def phone_number
      if rand(0..1) == 1
        home_phone_number
      else
        mobile_phone_number
      end
    end

    def home_phone_number
      number HOME_PHONE_PREFIXES
    end

    def mobile_phone_number
      number MOBILE_PHONE_PREFIXES
    end

    def number(prefixes)
      p = [
        COUNTRY_PREFIX.rand,
        prefixes.rand,
        random_space,
        PHONE_NUMBER.rand
      ].join('')

      Faker.numerify p
    end

    def random_space
      rand(0..1) == 1 ? ' ' : ''
    end

    COUNTRY_PREFIX = k ['+39', '0039', '+39 ', '0039 ']
    PHONE_NUMBER = k ['######', '########']
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffaker-1.30.0 lib/ffaker/phone_number_it.rb
ffaker-1.25.0 lib/ffaker/phone_number_it.rb
ffaker-1.24.0 lib/ffaker/phone_number_it.rb