Sha256: 4e431f861ccddb8a41e3248b74904401f92c98da39d6056ebe613333215b0068

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 Bytes

Contents

# encoding: utf-8

require 'ostruct'

module Faker
  module Unit
    extend ModuleUtils
    extend self

    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

    TIME_UNITS = k [
      {:name => 'Years', :abbreviation => 'yr'},
      {:name => 'Days', :abbreviation => 'd'},
      {:name => 'Hours', :abbreviation => 'Minutes'},
      {:name => 'Seconds', :abbreviation => 's'},
      {:name => 'Milliseconds', :abbreviation => 'msec'}
    ]

    TEMPERATURE_UNITS = k [
      {:name => 'Kelvin', :abbreviation => 'K'},
      {:name => 'Celsius', :abbreviation => 'C'},
      {:name => 'Fahrenheit', :abbreviation => 'F'}
    ]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffaker-1.31.0 lib/ffaker/unit.rb