Sha256: 6994e13793289846257b8c2a556e05e1910484e36a309b2ce0567b70ac2c0fe2

Contents?: true

Size: 951 Bytes

Versions: 7

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true

module FFaker
  module Unit
    extend ModuleUtils
    extend self

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

    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
      fetch_sample(TIME_UNITS)
    end

    def temperature
      fetch_sample(TEMPERATURE_UNITS)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ffaker-2.23.0 lib/ffaker/unit.rb
ffaker-2.22.0 lib/ffaker/unit.rb
ffaker-2.21.0 lib/ffaker/unit.rb
ffaker-2.20.0 lib/ffaker/unit.rb
ffaker-2.19.0 lib/ffaker/unit.rb
ffaker-2.18.0 lib/ffaker/unit.rb
ffaker-2.17.0 lib/ffaker/unit.rb