class Faker::PhoneNumber
Public Class Methods
area_code()
click to toggle source
US and Canada only
# File lib/faker/default/phone_number.rb, line 27 def area_code fetch('phone_number.area_code') rescue I18n::MissingTranslationData nil end
cell_phone()
click to toggle source
# File lib/faker/default/phone_number.rb, line 10 def cell_phone parse('cell_phone.formats') end
cell_phone_with_country_code()
click to toggle source
# File lib/faker/default/phone_number.rb, line 22 def cell_phone_with_country_code "#{country_code} #{cell_phone}" end
country_code()
click to toggle source
# File lib/faker/default/phone_number.rb, line 14 def country_code "+#{fetch('country_code')}" end
exchange_code()
click to toggle source
US and Canada only
# File lib/faker/default/phone_number.rb, line 34 def exchange_code fetch('phone_number.exchange_code') rescue I18n::MissingTranslationData nil end
phone_number()
click to toggle source
# File lib/faker/default/phone_number.rb, line 6 def phone_number parse('phone_number.formats') end
phone_number_with_country_code()
click to toggle source
# File lib/faker/default/phone_number.rb, line 18 def phone_number_with_country_code "#{country_code} #{phone_number}" end
subscriber_number(legacy_length = NOT_GIVEN, length: 4)
click to toggle source
US and Canada only Can be used for both extensions and last four digits of phone number. Since extensions can be of variable length, this method taks a length parameter
# File lib/faker/default/phone_number.rb, line 43 def subscriber_number(legacy_length = NOT_GIVEN, length: 4) warn_for_deprecated_arguments do |keywords| keywords << :length if legacy_length != NOT_GIVEN end rand.to_s[2..(1 + length)] end
Also aliased as: extension