class Kelvin::Temperature

Included Modules

Defined in:

kelvin/temperature.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(kelvin : Float = 0.0) #

Initializes a new Temperature with the given value in Kelvin. The default is 0 K, which corresponds with -273.15 °C.


[View source]
def self.new(kelvin) #

[View source]

Class Method Detail

def self.boiling_point #

The boiling point of water (under precisely defined circumstances); 100 °C


[View source]
def self.celcius(degrees_celcius : Float) #

Make a new Temperature using a reading in degrees Celcius.


[View source]
def self.fahrenheit(degrees_fahrenheit : Float) #

Make a new Temperature using a reading in degrees Fahrenheit.


[View source]
def self.freezing_point #

The freezing point of water; 0 °C


[View source]
def self.parse(string : String) #

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")

[View source]
def self.water_boiling_point #

The boiling point of water (under precisely defined circumstances); 100 °C


[View source]
def self.water_freezing_point #

The freezing point of water; 0 °C


[View source]
def self.water_triple_point #

Triple point of water; 0.01 °C

See: https://en.wikipedia.org/wiki/Triple_point


[View source]
def self.zero #

absolute zero. -273.15 °C.


[View source]

Instance Method Detail

def *(factor) #

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

[View source]
def +(other) #

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.


[View source]
def -(other) #

Subtract other from self. Returns a new Temperature. The remarks for #+ apply here too.


[View source]
def /(divisor) #

Subtract other from self. Returns a new Temperature. The remarks for #+ apply here too.


[View source]
def <=>(other) #

Compare two temperatures


[View source]
def to_celcius #

Returns a Float with the temperature in degrees Celcius


[View source]
def to_f : Float64 #

Returns a Float with the temperature in Kelvin


[View source]
def to_fahrenheit #

Returns a Float with the temperature in degrees Fahrenheit


[View source]
def to_kelvin : Float64 #

Returns a Float with the temperature in Kelvin


[View source]
def to_s(io) #

Output the temperature in the scale that's default for the current locale settings.


[View source]