Sha256: dfb45afc19070dc04985c3c7796c913a873402736fa43b5652a8c815751fe495

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true

module FFakerTW
  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

    private

    def number(prefixes)
      pattern = [
        fetch_sample(COUNTRY_PREFIX),
        fetch_sample(prefixes),
        random_space,
        fetch_sample(PHONE_NUMBER)
      ].join

      FFakerTW.numerify(pattern)
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffakerTW-0.1.0 lib/ffakerTW/phone_number_it.rb