lib/uom/measurement.rb in uom-1.2.1 vs lib/uom/measurement.rb in uom-1.2.2
- old
+ new
@@ -1,9 +1,11 @@
require 'forwardable'
require 'uom/error'
require 'uom/units'
+# UOM implements Units of Measurement based on the International System of Units.
+# See [http://github.com/caruby/uom] for details.
module UOM
# Measurement qualifies a quantity with a unit.
class Measurement
extend Forwardable
@@ -108,10 +110,10 @@
# Commas and a non-numeric prefix are removed if present.
# Returns nil if this is not a measurement string.
# If unit is given, then this method converts the measurement to the given unit.
def to_measurement_quantity(unit=nil)
# remove commas
- return to_measurement_quantity(delete(',')) if self[',']
+ return delete(',').to_measurement_quantity(unit) if self[',']
# extract the quantity portion
quantity_s = self[/\d*\.?\d*/]
return if quantity_s.nil? or quantity_s == '.'
quantity = quantity_s['.'] ? quantity_s.to_f : quantity_s.to_i
# extract the unit portion
\ No newline at end of file