Sha256: c44a761ca33f9d348c16fcce65c810f384c8d9477d660e938286dc07fb6866f5

Contents?: true

Size: 921 Bytes

Versions: 12

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

module FFaker
  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)
      FFaker.numerify([LOCAL_PREFIX, fetch_sample(prefixes), PHONE_NUMBER].join(''))
    end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ffaker-2.23.0 lib/ffaker/phone_number_ua.rb
ffaker-2.22.0 lib/ffaker/phone_number_ua.rb
ffaker-2.21.0 lib/ffaker/phone_number_ua.rb
ffaker-2.20.0 lib/ffaker/phone_number_ua.rb
ffaker-2.19.0 lib/ffaker/phone_number_ua.rb
ffaker-2.18.0 lib/ffaker/phone_number_ua.rb
ffaker-2.17.0 lib/ffaker/phone_number_ua.rb
ffaker-2.16.0 lib/ffaker/phone_number_ua.rb
ffaker-2.15.0 lib/ffaker/phone_number_ua.rb
ffaker-2.14.0 lib/ffaker/phone_number_ua.rb
ffaker-2.13.0 lib/ffaker/phone_number_ua.rb
ffaker-2.12.0 lib/ffaker/phone_number_ua.rb