Sha256: fc0b920e5a731d8c86aef06e6fe97def94a38006cf0eb0002e6f84610c32150c

Contents?: true

Size: 898 Bytes

Versions: 3

Compression:

Stored size: 898 Bytes

Contents

# encoding: utf-8

require 'ostruct'

module FFaker
  module Unit
    extend ModuleUtils
    extend self

    TIME_UNITS = [
      {name: 'Years', abbreviation: 'yr'},
      {name: 'Days', abbreviation: 'd'},
      {name: 'Hours', abbreviation: 'Minutes'},
      {name: 'Seconds', abbreviation: 's'},
      {name: 'Milliseconds', abbreviation: 'msec'}
    ]
    TEMPERATURE_UNITS = [
      {name: 'Kelvin', abbreviation: 'K'},
      {name: 'Celsius', abbreviation: 'C'},
      {name: 'Fahrenheit', abbreviation: 'F'}
    ]

    def time_name
      time.name
    end

    def time_abbr
      time.abbreviation
    end

    def temperature_name
      temperature.name
    end

    def temperature_abbr
      temperature.abbreviation
    end

    private

    def time
      OpenStruct.new TIME_UNITS.sample
    end

    def temperature
      OpenStruct.new TEMPERATURE_UNITS.sample
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffaker-2.2.0 lib/ffaker/unit.rb
ffaker-2.1.0 lib/ffaker/unit.rb
ffaker-2.0.0 lib/ffaker/unit.rb