Sha256: c86912372cf6a8304b4938a31f25dadd4c5486467ab8ed2d573bada6994d7925

Contents?: true

Size: 755 Bytes

Versions: 8

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

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

8 entries across 8 versions & 1 rubygems

Version Path
ffaker-2.19.0 lib/ffaker/phone_number_it.rb
ffaker-2.18.0 lib/ffaker/phone_number_it.rb
ffaker-2.17.0 lib/ffaker/phone_number_it.rb
ffaker-2.16.0 lib/ffaker/phone_number_it.rb
ffaker-2.15.0 lib/ffaker/phone_number_it.rb
ffaker-2.14.0 lib/ffaker/phone_number_it.rb
ffaker-2.13.0 lib/ffaker/phone_number_it.rb
ffaker-2.12.0 lib/ffaker/phone_number_it.rb