alchemist
alchemist copied to clipboard
Better to_s
Right now, alchemist provides very basic to_s
methods. In the case of a simple measurement, they simply convert the float version of the measurement to a string:
irb(main):003:0> 1.meter.to_s
=> "1.0"
irb(main):004:0> 3.seconds.to_s
=> "3.0"
In the case of compound measurements, they don't even do that much:
irb(main):005:0> 2.meters.per.second.to_s
=> "#<Alchemist::CompoundMeasurement:0x007ff3c18e9060>"
irb(main):006:0>
It'd be awesome if it printed nice strings for these:
=> 1.meter.to_s
"1 meter"
=> 3.seconds.to_s
"3 seconds"
=> 1.s.to_s
"1 second"
=> 30.miles.per.hour
"30 miles/hour"
This is on my list of todos. Not sure when I'll get to it though.