unitwise
unitwise copied to clipboard
update: prioritise atomic units to prefixed units
Hi, first of all I'd like to thank you for making this fantastic gem. I've been trialing this gem for basic unit conversions, and it's worked out great for me so far.
Because I'm using this gem for basic unit parsing, I had the same issue as #16, where parsing 'ft'
gave me back femto tonne
instead of the desired unit foot
. This PR is intended to change that so exact atomic unit matches are prioritised over prefixed matches.
Obviously this breaks the original parsing precedence of metric > rest, and may not be what you desire. Maybe we can add a configuration object for toggling the parsing precedence?
This seems pretty reasonable. I'd wager that the number of people attempting to parse ft
to foot
is orders of magnitude higher than the number of people that actually want femto tonne
😄