https://github.com/tijn/kelvin
A small library for working with temperatures in Crystal
https://github.com/tijn/kelvin
celcius crystal crystal-lang fahrenheit fahrenheit-to-centigrade kelvin temperature
Last synced: about 1 year ago
JSON representation
A small library for working with temperatures in Crystal
- Host: GitHub
- URL: https://github.com/tijn/kelvin
- Owner: tijn
- License: mit
- Created: 2018-01-02T21:35:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-09T09:51:10.000Z (almost 6 years ago)
- Last Synced: 2025-01-03T15:12:12.859Z (about 1 year ago)
- Topics: celcius, crystal, crystal-lang, fahrenheit, fahrenheit-to-centigrade, kelvin, temperature
- Language: Crystal
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Kelvin
[](https://travis-ci.org/tijn/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`:
```yaml
dependencies:
kelvin:
github: tijn/kelvin
```
## Usage
```crystal
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:
```crystal
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.
```crystal
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
1. Fork it ( https://github.com/tijn/kelvin/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [tijn](https://github.com/tijn) Tijn Schuurmans - creator, maintainer