Class: Faker::Base

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

Direct Known Subclasses

Address, Career, Company, Internet, Lorem, Name, PhoneNumber

Class Method Summary collapse

Class Method Details

.bothify(string) ⇒ Object



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

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



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

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

.letterify(letter_string) ⇒ Object



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

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

.numerify(number_string) ⇒ Object



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

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