unitwise icon indicating copy to clipboard operation
unitwise copied to clipboard

update: prioritise atomic units to prefixed units

Open pRdm opened this issue 7 years ago • 1 comments

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?

pRdm avatar Feb 02 '18 06:02 pRdm

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 😄

bgentry avatar Jun 27 '18 23:06 bgentry