Sha256: 66fe1fbf3460f691b8f54a88ab6a5b444605e66d570be43501e7ec9a90c45c96

Contents?: true

Size: 839 Bytes

Versions: 2

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

module FFaker
  module PhoneNumberID
    extend ModuleUtils
    extend self

    COUNTRY_CODE = '+62'

    def mobile_phone_number
      "#{fetch_sample(MOBILE_PHONE_PREFIXES)}-#{FFaker.numerify('########')}"
    end

    def home_phone_number
      digit_nums = '#' * rand(7..8)

      "#{fetch_sample(HOME_PHONE_PREFIXES)}-#{FFaker.numerify(digit_nums)}"
    end

    def phone_number
      case rand(2)
      when 0 then home_phone_number
      when 1 then mobile_phone_number
      end
    end

    def international_mobile_phone_number
      mobile_phone_number.sub('0', COUNTRY_CODE)
    end

    def international_home_phone_number
      home_phone_number.sub('0', COUNTRY_CODE)
    end

    def international_phone_number
      phone_number.sub('0', COUNTRY_CODE)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffaker-2.5.0 lib/ffaker/phone_number_id.rb
ffaker-2.4.0 lib/ffaker/phone_number_id.rb