Sha256: 60abc78c4c0d41993f34d702dea0cb75e4b09c50924e7cebc7beeaebb0dbbdcc

Contents?: true

Size: 897 Bytes

Versions: 5

Compression:

Stored size: 897 Bytes

Contents

# encoding: utf-8

require 'ostruct'

module Faker
  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

5 entries across 5 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/ffaker-1.32.1/lib/ffaker/unit.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/ffaker-1.32.1/lib/ffaker/unit.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/ffaker-1.32.1/lib/ffaker/unit.rb
ffaker-1.32.1 lib/ffaker/unit.rb
ffaker-1.32.0 lib/ffaker/unit.rb