Skip to content
/ kelvin Public

A small library for working with temperatures in Crystal

License

Notifications You must be signed in to change notification settings

tijn/kelvin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kelvin

Build Status

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

  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 Tijn Schuurmans - creator, maintainer

Releases

No releases published

Packages

No packages published