Sha256: 9309bcdfdbe27f2b2d576093d706f0a0200d43836ae7edc644c177fe90bb9d87

Contents?: true

Size: 743 Bytes

Versions: 10

Compression:

Stored size: 743 Bytes

Contents

# encoding: utf-8

module FFaker
  module PhoneNumberIT
    extend ModuleUtils
    extend self

    COUNTRY_PREFIX = ['+39', '0039', '+39 ', '0039 '].freeze
    PHONE_NUMBER = ['######', '########'].freeze

    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.sample,
        prefixes.sample,
        random_space,
        PHONE_NUMBER.sample
      ].join('')

      FFaker.numerify p
    end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ffaker-2.11.0 lib/ffaker/phone_number_it.rb
ffaker-2.10.0 lib/ffaker/phone_number_it.rb
ffaker-2.9.0 lib/ffaker/phone_number_it.rb
ffaker-2.8.1 lib/ffaker/phone_number_it.rb
ffaker-2.8.0 lib/ffaker/phone_number_it.rb
ffaker-2.7.0 lib/ffaker/phone_number_it.rb
ffaker-2.6.0 lib/ffaker/phone_number_it.rb
ffaker-2.5.0 lib/ffaker/phone_number_it.rb
ffaker-2.4.0 lib/ffaker/phone_number_it.rb
ffaker-2.3.0 lib/ffaker/phone_number_it.rb