kelvin
Kelvin
A small library for handling temperatures.
It's as precise as a 64 bit Float.
Installation
Add this to your application's shard.yml
:
dependencies:
kelvin:
github: tijn/kelvin
Usage
require "kelvin"
temperature = Kelvin::Temperature.celcius(22.3)
puts temperature
# => "22.3 °C" : String
# or if you're in the US, it will output: "72.1 °F" : String
# It follows the LOCALE settings on your system.
puts temperature.to_kelvin
# => 295.45
It can also parse text:
require "kelvin"
temperature = Kelvin::Temperature.parse("22.3 °C")
puts temperature
# => "22.3 °C" : String
and you can use it to compare temperatures on different scales.
temperature_in_paris = Kelvin::Temperature.parse("22.3 °C")
temperature_in_boston = Kelvin::Temperature.parse("70.1 °F")
city = (temperature_in_paris > temperature_in_boston) ? "Paris" : "Boston"
puts "#{city} is warmer today"
Development
TODO: Write development instructions here
Contributing
- Fork it ( https://github.com/tijn/kelvin/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- tijn Tijn Schuurmans - creator, maintainer
Repository
kelvin
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- over 4 years ago
- January 2, 2018
License
MIT License
Links
Synced at
Thu, 07 Nov 2024 23:37:55 GMT
Languages