As I’ve been working on my weather station at home at nights, I realized the code would be a lot cleaner if I wasn’t constantly keeping track of temperature units. So I created the Temperature module for Ruby which adds methods to numbers to make them implicitly temperatures, as well as a parsing method on strings. To get a flavor of it, here are some examples:
freezing_in_F = 32 freezing_in_C = freezing_in_F.to_C boiling_in_C = 100 boiling_in_C.units = "C" boiling_in_F = boiling_in_C.to_F absolute_zero = "0K".to_degrees absolute_zero_in_C = absolute_zero.to_C absolute_zero_in_F = absolute_zero.to_F
The full documentation for the project is on rubyforge. Gems, tar, and zip format have all been published, and it should be propagating out to the main gem servers tonight. It’s not exceptionally complicated, however it is convenient, and it’s even got 236 unit tests to ensure it’s doing things right. The code is released under the MIT license, so you are pretty much able to do anything you want with it.