Sha256: 2fad25093aa1f61a166e5dd91d2b643943f5325ee12802ccc8f2c147727b9513

Contents?: true

Size: 946 Bytes

Versions: 8

Compression:

Stored size: 946 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.rand
    end

    def temperature
      OpenStruct.new TEMPERATURE_UNITS.rand
    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

8 entries across 8 versions & 2 rubygems

Version Path
ffaker-1.30.0 lib/ffaker/unit.rb
ffaker-1.25.0 lib/ffaker/unit.rb
ffaker-1.24.0 lib/ffaker/unit.rb
ffakerer-1.0.2 lib/ffakerer/unit.rb
ffaker-1.23.0 lib/ffaker/unit.rb
ffakerer-1.0.1 lib/ffakerer/unit.rb
ffaker-1.22.1 lib/ffaker/unit.rb
ffaker-1.22.0 lib/ffaker/unit.rb