Shopify / measured

Encapsulate measurements and their units in Ruby and Ruby on Rails.
MIT License
337 stars 28 forks source link

On initialize, convert strings to rational if they follow rational pattern #149

Closed dvisockas closed 1 year ago

dvisockas commented 1 year ago

Adds support to initialize Measured object with a rational value from string (currently raises):

Measured::Weight.new("1/3", :g).value
#=> (1/3)

Fixes https://github.com/Shopify/measured/issues/148

Question: how can this be further tested?

kmcphillips commented 1 year ago

This is good! Seems like a clean fix.

Thank you for your contribution. I'll try to do a release soon, but I'm on parental leave so I make no time commitments. You can use the github hash for now.