WeightConversion (0.2.0)
Weight object for converting from grams, ounces, pounds and kilograms into a common unit.
Based on Anton Shemerey's Weight gem (https://github.com/shemerey/weight)
Installation
Add this line to your application's Gemfile:
$ gem 'weight_conversion'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install weight_conversion
Usage
Basic Conversion
Weight.new(1, :lb).to_kgs
Weight.new(1, :kg).to_mgs
Basic Math with Weight objects
Weight.new(1, :kg) + Weight.new(1, :kg) == Weight.new(2, :kg)
Weight.new(1, :kg) - Weight.new(1, :kg) == Weight.new(0, :kg)
Weight.new(1, :kg) * 2 == Weight.new(2, :kg)
Weight.new(2, :kg) / 2 == Weight.new(1, :kg)
Convert result to the first object unit system
Weight.new(1, :kg) + Weight.new(1, :lb)
Weight.new(1, :lb) + Weight.new(1, :kg)
Basic comparison with Weight objects
Weight.new(3, :lb).between?(Weight.new(1, :kg), Weight.new(2, :kg))
Weight.new(1, :kg) > Weight.new(2, :lb)
Weight.new(1, :lb) <= Weight.new(0.5, :kg)
Contributing
- Fork it ( https://github.com/[my-github-username]/weight_conversion/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