class Kelvin::Temperature
- Kelvin::Temperature
- Reference
- Object
Included Modules
- Comparable(Kelvin::Temperature)
Defined in:
kelvin/temperature.crConstructors
-
.new(kelvin : Float = 0.0)
Initializes a new
Temperature
with the given value in Kelvin. - .new(kelvin)
Class Method Summary
-
.boiling_point
The boiling point of water (under precisely defined circumstances); 100 °C
-
.celcius(degrees_celcius : Float)
Make a new
Temperature
using a reading in degrees Celcius. -
.fahrenheit(degrees_fahrenheit : Float)
Make a new
Temperature
using a reading in degrees Fahrenheit. -
.freezing_point
The freezing point of water; 0 °C
-
.parse(string : String)
Returns a new
Temperature
by parsing string. -
.water_boiling_point
The boiling point of water (under precisely defined circumstances); 100 °C
-
.water_freezing_point
The freezing point of water; 0 °C
-
.water_triple_point
Triple point of water; 0.01 °C
-
.zero
absolute zero.
Instance Method Summary
-
#*(factor)
Multiply the temperature by a factor.
-
#+(other)
Sum two temperatures.
-
#-(other)
Subtract other from
self
. -
#/(divisor)
Subtract other from
self
. -
#<=>(other)
Compare two temperatures
-
#to_celcius
Returns a
Float
with the temperature in degrees Celcius -
#to_f : Float64
Returns a
Float
with the temperature in Kelvin -
#to_fahrenheit
Returns a
Float
with the temperature in degrees Fahrenheit -
#to_kelvin : Float64
Returns a
Float
with the temperature in Kelvin -
#to_s(io)
Output the temperature in the scale that's default for the current locale settings.
Constructor Detail
Initializes a new Temperature
with the given value in Kelvin.
The default is 0 K, which corresponds with -273.15 °C.
Class Method Detail
Make a new Temperature
using a reading in degrees Celcius.
Make a new Temperature
using a reading in degrees Fahrenheit.
Returns a new Temperature
by parsing string.
For example:
Kelvin::Temperature.parse("22.3 °C")
Kelvin::Temperature.parse("82.10 °F")
Kelvin::Temperature.parse("273.15 K")
The boiling point of water (under precisely defined circumstances); 100 °C
Triple point of water; 0.01 °C
See: https://en.wikipedia.org/wiki/Triple_point
Instance Method Detail
Multiply the temperature by a factor. Note that the outcome may be very different from what you might expect:
Temperature.parse("10 °C") * 2 # => XXXX
Sum two temperatures. Note that the outcome may be very different from what you might expect:
Temperature.parse("10 °C") + Temperature.parse("20 °C") # => 303.2 °C
The reason for this is that its only meaningful to add or subtract temperatures in Kelvin.
Subtract other from self
. Returns a new Temperature. The remarks for #+
apply here too.
Subtract other from self
. Returns a new Temperature. The remarks for #+
apply here too.