Module: Faker

Extended by:
ModuleUtils
Defined in:
lib/ffaker.rb,
lib/ffaker/ssn.rb,
lib/ffaker/job.rb,
lib/ffaker/food.rb,
lib/ffaker/time.rb,
lib/ffaker/name.rb,
lib/ffaker/guid.rb,
lib/ffaker/unit.rb,
lib/ffaker/venue.rb,
lib/ffaker/movie.rb,
lib/ffaker/skill.rb,
lib/ffaker/color.rb,
lib/ffaker/lorem.rb,
lib/ffaker/ssn_mx.rb,
lib/ffaker/job_fr.rb,
lib/ffaker/ssn_se.rb,
lib/ffaker/string.rb,
lib/ffaker/gender.rb,
lib/ffaker/job_ja.rb,
lib/ffaker/locale.rb,
lib/ffaker/name_se.rb,
lib/ffaker/vehicle.rb,
lib/ffaker/name_de.rb,
lib/ffaker/name_fr.rb,
lib/ffaker/name_ga.rb,
lib/ffaker/name_ru.rb,
lib/ffaker/name_it.rb,
lib/ffaker/name_sn.rb,
lib/ffaker/name_nl.rb,
lib/ffaker/name_th.rb,
lib/ffaker/name_vn.rb,
lib/ffaker/name_cn.rb,
lib/ffaker/address.rb,
lib/ffaker/product.rb,
lib/ffaker/name_kr.rb,
lib/ffaker/name_br.rb,
lib/ffaker/name_ja.rb,
lib/ffaker/name_da.rb,
lib/ffaker/name_mx.rb,
lib/ffaker/boolean.rb,
lib/ffaker/name_cs.rb,
lib/ffaker/company.rb,
lib/ffaker/name_ph.rb,
lib/ffaker/name_nb.rb,
lib/ffaker/lorem_cn.rb,
lib/ffaker/internet.rb,
lib/ffaker/lorem_ar.rb,
lib/ffaker/lorem_fr.rb,
lib/ffaker/gender_cn.rb,
lib/ffaker/education.rb,
lib/ffaker/conference.rb,
lib/ffaker/address_se.rb,
lib/ffaker/address_fi.rb,
lib/ffaker/company_se.rb,
lib/ffaker/address_ca.rb,
lib/ffaker/address_au.rb,
lib/ffaker/company_it.rb,
lib/ffaker/address_us.rb,
lib/ffaker/address_sn.rb,
lib/ffaker/address_da.rb,
lib/ffaker/address_de.rb,
lib/ffaker/address_mx.rb,
lib/ffaker/address_fr.rb,
lib/ffaker/address_nl.rb,
lib/ffaker/address_uk.rb,
lib/ffaker/address_br.rb,
lib/ffaker/html_ipsum.rb,
lib/ffaker/bacon_ipsum.rb,
lib/ffaker/geolocation.rb,
lib/ffaker/internet_se.rb,
lib/ffaker/unit_metric.rb,
lib/ffaker/phone_number.rb,
lib/ffaker/unit_english.rb,
lib/ffaker/dizzle_ipsum.rb,
lib/ffaker/hipster_ipsum.rb,
lib/ffaker/nato_alphabet.rb,
lib/ffaker/identification.rb,
lib/ffaker/phone_number_da.rb,
lib/ffaker/phone_number_se.rb,
lib/ffaker/phone_number_it.rb,
lib/ffaker/phone_number_fr.rb,
lib/ffaker/phone_number_sg.rb,
lib/ffaker/phone_number_au.rb,
lib/ffaker/phone_number_de.rb,
lib/ffaker/phone_number_mx.rb,
lib/ffaker/phone_number_nl.rb,
lib/ffaker/phone_number_sn.rb,
lib/ffaker/healthcare_ipsum.rb,
lib/ffaker/identification_es.rb,
lib/ffaker/utils/array_utils.rb,
lib/ffaker/identification_mx.rb,
lib/ffaker/utils/module_utils.rb,
lib/ffaker/identification_es_cl.rb,
lib/ffaker/identification_es_co.rb

Defined Under Namespace

Modules: Address, AddressAU, AddressBR, AddressCA, AddressDA, AddressDE, AddressFI, AddressFR, AddressMX, AddressNL, AddressSE, AddressSN, AddressUK, AddressUS, ArrayUtils, BaconIpsum, Boolean, Color, Company, CompanyIT, CompanySE, Conference, DizzleIpsum, Education, Food, Gender, GenderCN, Geolocation, Guid, HTMLIpsum, HealthcareIpsum, HipsterIpsum, Identification, IdentificationES, IdentificationESCL, IdentificationESCO, IdentificationMX, Internet, InternetSE, Job, JobFR, JobJA, Locale, Lorem, LoremAR, LoremCN, LoremFR, ModuleUtils, Movie, Name, NameBR, NameCN, NameCS, NameDA, NameDE, NameFR, NameGA, NameIT, NameJA, NameKR, NameMX, NameNB, NameNL, NamePH, NameRU, NameSE, NameSN, NameTH, NameVN, NatoAlphabet, PhoneNumber, PhoneNumberAU, PhoneNumberDA, PhoneNumberDE, PhoneNumberFR, PhoneNumberIT, PhoneNumberMX, PhoneNumberNL, PhoneNumberSE, PhoneNumberSG, PhoneNumberSN, Product, SSN, SSNMX, SSNSE, Skill, String, Time, Unit, UnitEnglish, UnitMetric, Vehicle, Venue

Constant Summary

VERSION =
"1.25.0"
BASE_LIB_PATH =
File.expand_path("..", __FILE__)
LETTERS =
k('a'..'z')
HEX =
%w(0 1 2 3 4 5 6 7 8 9 A B C D E F)

Class Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Class Method Details

.bothify(masks) ⇒ Object



33
34
35
# File 'lib/ffaker.rb', line 33

def self.bothify(masks)
  letterify(numerify(masks))
end

.hexify(*masks) ⇒ Object



15
16
17
18
19
# File 'lib/ffaker.rb', line 15

def self.hexify(*masks)
  mask = ArrayUtils.rand(masks.flatten)
  mask.gsub!(/#/) { ArrayUtils.rand(HEX) }
  mask
end

.letterify(*masks) ⇒ Object



27
28
29
30
31
# File 'lib/ffaker.rb', line 27

def self.letterify(*masks)
  mask = ArrayUtils.rand(masks.flatten)
  mask.gsub!(/\?/) { LETTERS.rand }
  mask
end

.numerify(*masks) ⇒ Object



21
22
23
24
25
# File 'lib/ffaker.rb', line 21

def self.numerify(*masks)
  mask = ArrayUtils.rand(masks.flatten)
  mask.gsub!(/#/) { rand(10).to_s }
  mask
end