Class: Faker::Demographic

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

Constant Summary

Constants inherited from Base

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

Class Method Summary collapse

Methods inherited from Base

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

Class Method Details

.demonymObject



12
13
14
# File 'lib/faker/demographic.rb', line 12

def demonym
  fetch('demographic.demonym')
end

.educational_attainmentObject



8
9
10
# File 'lib/faker/demographic.rb', line 8

def educational_attainment
  fetch('demographic.educational_attainment')
end

.height(unit = :metric) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/faker/demographic.rb', line 24

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

.marital_statusObject



16
17
18
# File 'lib/faker/demographic.rb', line 16

def marital_status
  fetch('demographic.marital_status')
end

.raceObject



4
5
6
# File 'lib/faker/demographic.rb', line 4

def race
  fetch('demographic.race')
end

.sexObject



20
21
22
# File 'lib/faker/demographic.rb', line 20

def sex
  fetch('demographic.sex')
end