Class: Faker::PhoneNumber
Constant Summary
Constants inherited from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.area_code ⇒ Object
US and Canada only.
- .cell_phone ⇒ Object
-
.exchange_code ⇒ Object
US and Canada only.
- .phone_number ⇒ Object
-
.subscriber_number(length = 4) ⇒ Object
(also: extension)
US and Canada only Can be used for both extensions and last four digits of phone number.
Methods inherited from Base
bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.area_code ⇒ Object
US and Canada only
13 14 15 16 17 |
# File 'lib/faker/phone_number.rb', line 13 def area_code fetch('phone_number.area_code') rescue I18n::MissingTranslationData nil end |
.cell_phone ⇒ Object
8 9 10 |
# File 'lib/faker/phone_number.rb', line 8 def cell_phone parse('cell_phone.formats') end |
.exchange_code ⇒ Object
US and Canada only
20 21 22 23 24 |
# File 'lib/faker/phone_number.rb', line 20 def exchange_code fetch('phone_number.exchange_code') rescue I18n::MissingTranslationData nil end |
.phone_number ⇒ Object
4 5 6 |
# File 'lib/faker/phone_number.rb', line 4 def phone_number parse('phone_number.formats') end |
.subscriber_number(length = 4) ⇒ Object Also known as: extension
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
29 30 31 |
# File 'lib/faker/phone_number.rb', line 29 def subscriber_number(length = 4) rand.to_s[2..(1 + length)] end |