Class: Faker::Demographic

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

Constant Summary

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.demonymObject



14
15
16
# File 'lib/faker/default/demographic.rb', line 14

def demonym
  fetch('demographic.demonym')
end

.educational_attainmentObject



10
11
12
# File 'lib/faker/default/demographic.rb', line 10

def educational_attainment
  fetch('demographic.educational_attainment')
end

.height(unit = :metric) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/faker/default/demographic.rb', line 26

def height(unit = :metric)
  case unit
  when :imperial
    inches = rand_in_range(57, 86)
    "#{inches / 12} ft, #{inches % 12} in"
  when :metric
    rand_in_range(1.45, 2.13).round(2).to_s
  end
end

.marital_statusObject



18
19
20
# File 'lib/faker/default/demographic.rb', line 18

def marital_status
  fetch('demographic.marital_status')
end

.raceObject



6
7
8
# File 'lib/faker/default/demographic.rb', line 6

def race
  fetch('demographic.race')
end

.sexObject



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

def sex
  fetch('demographic.sex')
end