Issues converting from meters to Kilometers
stevebooks opened this issue · comments
Using version 0.1.7
require 'alchemist'
Alchemist.setup
21358.meters.to.kilometers
=> 21358.0
This is probably an issue with how I'm documenting this, but currently the way to get the value out in the correct unit is to call value
on the object
require 'alchemist'
Alchemist.setup
21358.meters.to.kilometers.value # => 21.358
Perhaps I need to restructure the internals to make it less confusing but as you can see when storing the information it's laid out like
#<Alchemist::Measurement:0x007fe6619bc180 @value=21.358, @unit_name=:meters, @exponent=1000.0>
Which means it doesn't actually hold on to the fact that it's supposed to be in kilometers and has instead stored the information via the exponent (I'm fairly certain I designed it this way to handle binary units). I'll reinvestigate this, but for now you should just call value.
Thanks