Sha256: 268fbea987c048790f4885320fac36b17c884e0cef1d4b690d1dd2732c78f25a

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

# frozen_string_literal: true

module FFakerTW
  module PhoneNumberUA
    extend ModuleUtils
    extend self

    LOCAL_PREFIX = '0'
    COUNTRY_PREFIX = '+380 '
    PHONE_NUMBER = ' ###-####'

    def phone_number
      rand(0..1).zero? ? home_phone_number : mobile_phone_number
    end

    def home_phone_number
      local_number(HOME_PHONE_PREFIXES)
    end

    def mobile_phone_number
      local_number(MOBILE_PHONE_PREFIXES)
    end

    def international_home_phone_number
      international_number(HOME_PHONE_PREFIXES)
    end

    def international_mobile_phone_number
      international_number(MOBILE_PHONE_PREFIXES)
    end

    private

    def local_number(prefixes)
      FFakerTW.numerify([LOCAL_PREFIX, fetch_sample(prefixes), PHONE_NUMBER].join(''))
    end

    def international_number(prefixes)
      FFakerTW.numerify([COUNTRY_PREFIX, fetch_sample(prefixes), PHONE_NUMBER].join(''))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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