Sha256: a8c65e1e7e085c7fafc416690647b27999f39971387bfad896a8c3753186db52

Contents?: true

Size: 707 Bytes

Versions: 8

Compression:

Stored size: 707 Bytes

Contents

module Faker
  class Demographic < Base
    class << self
      def race
        fetch('demographic.race')
      end

      def educational_attainment
        fetch('demographic.educational_attainment')
      end

      def demonym
        fetch('demographic.demonym')
      end

      def marital_status
        fetch('demographic.marital_status')
      end

      def sex
        fetch('demographic.sex')
      end

      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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
faker-1.8.7 lib/faker/demographic.rb
faker-1.8.6 lib/faker/demographic.rb
faker-1.8.5 lib/faker/demographic.rb
faker-1.8.4 lib/faker/demographic.rb
faker-1.8.3 lib/faker/demographic.rb
faker-1.8.2 lib/faker/demographic.rb
faker-1.8.0 lib/faker/demographic.rb
faker-1.7.3 lib/faker/demographic.rb