Sha256: a753b8087220354d5cf820bbf99cfa3191c62e880cbbb3c283be2c1b503d12ea

Contents?: true

Size: 616 Bytes

Versions: 2

Compression:

Stored size: 616 Bytes

Contents

require 'chemistry/temperature/unit'
require 'chemistry/temperature/celsius'

module Chemistry
  module Temperature
    class Kelvin < Chemistry::Temperature::Unit
      def to_kelvin
        self
      end

      def to_celsius
        Chemistry::Temperature::Celsius.new convert_to_celsius
      end

      def to_fahrenheit
        to_celsius.to_fahrenheit
      end

      def convert_to_celsius
        @temperature - 273.15
      end

      def ==(other)
        if other.kind_of? Chemistry::Temperature::Kelvin
          to_f == other.to_f
        else
          false
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chemistry-temperature-1.0.1 lib/chemistry/temperature/kelvin.rb
chemistry-temperature-1.0.0 lib/chemistry/temperature/kelvin.rb