class Faker::Demographic

Public Class Methods

demonym() click to toggle source

Produces a denonym.

@return [String]

@example

Faker::Demographic.denonym #=> "Panamanian"

@faker.version 1.7.3

# File lib/faker/default/demographic.rb, line 41
def demonym
  fetch('demographic.demonym')
end
educational_attainment() click to toggle source

Produces a level of educational attainment.

@return [String]

@example

Faker::Demographic.educational_attainment #=> "GED or alternative credential"

@faker.version 1.7.3

# File lib/faker/default/demographic.rb, line 28
def educational_attainment
  fetch('demographic.educational_attainment')
end
height(legacy_unit = NOT_GIVEN, unit: :metric) click to toggle source

Produces a height as a string.

@param unit [Symbol] either `:metric` or `imperial`. @return [String]

@example

Faker::Demographic.height #=> "1.61"

@example

Faker::Demographic.height(unit: :imperial) #=> "6 ft, 2 in"

@faker.version 1.7.3

# File lib/faker/default/demographic.rb, line 83
def height(legacy_unit = NOT_GIVEN, unit: :metric)
  warn_for_deprecated_arguments do |keywords|
    keywords << :unit if legacy_unit != NOT_GIVEN
  end

  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_status() click to toggle source

Produces a marital status.

@return [String]

@example

Faker::Demographic.marital_status #=> "Widowed"

@faker.version 1.7.3

# File lib/faker/default/demographic.rb, line 54
def marital_status
  fetch('demographic.marital_status')
end
race() click to toggle source

Produces the name of a race.

@return [String]

@example

Faker::Demographic.race #=> "Native Hawaiian or Other Pacific Islander"

@faker.version 1.7.3

# File lib/faker/default/demographic.rb, line 15
def race
  fetch('demographic.race')
end
sex() click to toggle source

Produces a sex for demographic purposes.

@return [String]

@example

Faker::Demographic.sex #=> "Female"

@faker.version 1.7.3

# File lib/faker/default/demographic.rb, line 67
def sex
  fetch('demographic.sex')
end