Open amingilani opened 6 years ago
The library currently supports converting to integers and floats, but for precise measurements, you should use decimal and currently converting directly doesn't work.
Example of current behavior:
distance = Unitwise(0.25, 'mile') # => #<Unitwise::Measurement value=0.25 unit=mile> distance.to_s # => "0.25 mile" distance.to_i # => 0 distance.to_f # => 0.25 distance.to_d # => Unitwise::ConversionError: Can't convert 0.25 mile to d. distance.to_f.to_d # => 0.25e0
Expected behavior:
distance.to_d => 0.25e0
The library currently supports converting to integers and floats, but for precise measurements, you should use decimal and currently converting directly doesn't work.
Example of current behavior:
Expected behavior: