class Faker::PhoneNumber
Public Instance Methods
area_code()
click to toggle source
US only
# File lib/faker/phone_number.rb, line 21 def area_code begin fetch('phone_number.area_code') rescue I18n::MissingTranslationData nil end end
cell_phone()
click to toggle source
# File lib/faker/phone_number.rb, line 12 def cell_phone if (translation = translate(:faker)[:cell_phone]).is_a? Hash numerify(translation[:formats].sample) else numerify(fetch('phone_number.formats')) end end
exchange_code()
click to toggle source
US only
# File lib/faker/phone_number.rb, line 30 def exchange_code begin fetch('phone_number.exchange_code') rescue I18n::MissingTranslationData nil end end
phone_number()
click to toggle source
# File lib/faker/phone_number.rb, line 4 def phone_number if parse('phone_number.formats') == "" numerify(fetch('phone_number.formats')) else parse('phone_number.formats') end end
subscriber_number(length = 4)
click to toggle source
US 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/phone_number.rb, line 41 def subscriber_number(length = 4) begin rand.to_s[2..(1 + length)] rescue I18n::MissingTranslationData nil end end