Class: Faker::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/faker.rb

Direct Known Subclasses

Address, Company, Internet, Lorem, Name, PhoneNumber

Class Method Summary collapse

Class Method Details

.bothify(string) ⇒ Object



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

def bothify(string)
  letterify(numerify(string))
end

.fetch(key) ⇒ Object

Helper for the common approach of grabbing a translation with an array of values and selecting one of them



37
38
39
# File 'lib/faker.rb', line 37

def fetch(key)
  I18n.translate("faker.#{key}").rand
end

.letterify(letter_string) ⇒ Object



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

def letterify(letter_string)
  letter_string.gsub(/\?/) { ('a'..'z').to_a.rand }
end

.numerify(number_string) ⇒ Object



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

def numerify(number_string)
  number_string.gsub(/#/) { rand(10).to_s }
end