Sha256: 3ee9611b8b757a64dfed70b1cd382a627c4cfeb9199b036656d216f643f5a61e

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

require 'convert_unit/base'
require 'convert_unit/pre_process/kinematic_viscosity/process'

module ConvertUnit
  class KinematicViscosity < Base
    extend PreProcess::KinematicViscosity
    UNITS_SYMBOL = load_units_symbol
    UNITS = load_available_units
    CONVERSION_RATE = load_conversion_rate

    attr_accessor :value, :unit

    def initialize(value, unit)
      unit_symbol = KinematicViscosity::UNITS_SYMBOL[unit] || unit
      @conversion_rate_for_one_unit = KinematicViscosity::CONVERSION_RATE
      super(value, unit_symbol, KinematicViscosity::UNITS)
    end

    def to(c_unit)
      c_unit.downcase!
      unit_symbol = KinematicViscosity::UNITS_SYMBOL[c_unit] || c_unit
      raise ArgumentError, 'Impossible conversion type' unless KinematicViscosity::UNITS.include?(unit_symbol)
      KinematicViscosity.new(convert_to(unit_symbol), unit_symbol)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
convert_unit-1.0.0 lib/convert_unit/kinematic_viscosity.rb