toKelvin method

num toKelvin(
  1. TemperatureUnit unit
)

convert num from unit to kelvin

Implementation

num toKelvin(TemperatureUnit unit) {
  switch (unit) {
    case TemperatureUnit.celsius:
      return this + 273.15;
    case TemperatureUnit.fahrenheit:
      return (this - 32) * 5 / 9 + 273.15;
    case TemperatureUnit.rankine:
      return this * 5 / 9;
    case TemperatureUnit.romer:
      return (this - 7.5) * 40 / 21 + 273.15;
    default:
      return this;
  }
}