Module: FFaker::PhoneNumberDE

Extended by:
ModuleUtils, PhoneNumberDE
Included in:
PhoneNumberDE
Defined in:
lib/ffaker/phone_number_de.rb

Overview

Author: lawitschka<moritz.lawitschka@urbanvention.com>

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#country_codeObject



35
36
37
# File 'lib/ffaker/phone_number_de.rb', line 35

def country_code
  '+49'
end

#home_work_phone_number(leading_zero = true) ⇒ Object



31
32
33
# File 'lib/ffaker/phone_number_de.rb', line 31

def home_work_phone_number(leading_zero = true)
  [region_prefix(leading_zero), FFaker.numerify('#######')].join(' ')
end

#international_home_work_phone_numberObject



43
44
45
# File 'lib/ffaker/phone_number_de.rb', line 43

def international_home_work_phone_number
  [country_code, home_work_phone_number(false)].join(' ')
end

#international_mobile_phone_numberObject



39
40
41
# File 'lib/ffaker/phone_number_de.rb', line 39

def international_mobile_phone_number
  [country_code, mobile_phone_number(false)].join(' ')
end

#international_phone_numberObject



47
48
49
# File 'lib/ffaker/phone_number_de.rb', line 47

def international_phone_number
  international_home_work_phone_number
end

#mobile_phone_number(leading_zero = true) ⇒ Object



27
28
29
# File 'lib/ffaker/phone_number_de.rb', line 27

def mobile_phone_number(leading_zero = true)
  [mobile_prefix(leading_zero), FFaker.numerify('#######')].join(' ')
end

#mobile_prefix(leading_zero = true) ⇒ Object

Mobile prefixes are in the 015x, 016x, 017x ranges



10
11
12
13
14
# File 'lib/ffaker/phone_number_de.rb', line 10

def mobile_prefix(leading_zero = true)
  mobile_prefix = '1' + (rand(3) + 5).to_s + rand(10).to_s
  mobile_prefix = '0' + mobile_prefix if leading_zero
  mobile_prefix
end

#phone_numberObject



23
24
25
# File 'lib/ffaker/phone_number_de.rb', line 23

def phone_number
  home_work_phone_number
end

#region_prefix(leading_zero = true) ⇒ Object

Region prefixes are in range 02..09 with length of 3 to 5 digits



17
18
19
20
21
# File 'lib/ffaker/phone_number_de.rb', line 17

def region_prefix(leading_zero = true)
  region_prefix = (rand(8) + 2).to_s + FFaker.numerify('#' * (rand(3) + 1)).to_s
  region_prefix = '0' + region_prefix if leading_zero
  region_prefix
end