Module: FFaker::PhoneNumberIT

Extended by:
ModuleUtils, PhoneNumberIT
Included in:
PhoneNumberIT
Defined in:
lib/ffaker/phone_number_it.rb

Constant Summary collapse

COUNTRY_PREFIX =
['+39', '0039', '+39 ', '0039 ']
PHONE_NUMBER =
['######', '########']

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#home_phone_numberObject


19
20
21
# File 'lib/ffaker/phone_number_it.rb', line 19

def home_phone_number
  number HOME_PHONE_PREFIXES
end

#mobile_phone_numberObject


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

def mobile_phone_number
  number MOBILE_PHONE_PREFIXES
end

#number(prefixes) ⇒ Object


27
28
29
30
31
32
33
34
35
36
# File 'lib/ffaker/phone_number_it.rb', line 27

def number(prefixes)
  p = [
    COUNTRY_PREFIX.sample,
    prefixes.sample,
    random_space,
    PHONE_NUMBER.sample
  ].join('')

  FFaker.numerify p
end

#phone_numberObject


11
12
13
14
15
16
17
# File 'lib/ffaker/phone_number_it.rb', line 11

def phone_number
  if rand(0..1) == 1
    home_phone_number
  else
    mobile_phone_number
  end
end

#random_spaceObject


38
39
40
# File 'lib/ffaker/phone_number_it.rb', line 38

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