Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for <unit> per N <unit> #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stwr667
Copy link
Contributor

@stwr667 stwr667 commented Nov 30, 2020

E.g. "2 kg/100kg" or "4 l/1000l".

It's similar to a percentage, but can be for any scalar number, and is often the terminology used in industry, rather than percentages. E.g. in Agriculture - adding 4 liters of Roundup per 100 liters of tank mixture.

Example unit definitions:

Unit.define('100kg') do |u|
  u.definition = Unit.new('100 kg')
  u.aliases = %w[100kg]
end

E.g. "2 kg/100kg" or "4 l/1000l".
It's similar to a percentage, but can be for any scalar number, and is
often the terminology used in industry, rather than percentages.
E.g. in Agriculture - adding 4 liters of Roundup per 100 liters of tank mixture.
@stwr667
Copy link
Contributor Author

stwr667 commented Nov 30, 2020

Hi @olbrich, we've used a forked version of Ruby-units for a while now, and are trying to get back to master. This PR is my attempt at fixing one of the last divergent behaviours that we have working locally, but cannot get working on the latest master version of ruby-units.
I've written specs to show the kind of behaviour we're aiming for. I've fixed a few of them. Although I'm not sure I've gone with the best approach. Multiplying these kinds of units, and adding doesn't quite work, and so I probably haven't set up the base units properly. If you have any guidance that would be great!
Thanks,
Steve.

@olbrich
Copy link
Owner

olbrich commented Dec 26, 2020

@stwr667 Sorry, I've been a bit slow to respond. I will be updating the gem to make sure ruby support has been updated now that Ruby 3.0 has been released. Once I'm done with that I will be taking a look at any outstanding PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants