Sha256: 797e0423d7f7070a4284f2646f9194b7bbaf45f009c0815f22584d21c78a7b38

Contents?: true

Size: 821 Bytes

Versions: 1

Compression:

Stored size: 821 Bytes

Contents

require 'convert_unit/base'
require 'convert_unit/pre_process/low_pressure/process'

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

    attr_accessor :value, :unit

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

    def to(c_unit)
      c_unit.downcase!
      unit_symbol = LowPressure::UNITS_SYMBOL[c_unit] || c_unit
      raise ArgumentError, 'Impossible conversion type' unless LowPressure::UNITS.include?(unit_symbol)
      LowPressure.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/low_pressure.rb