lib/ruby-measurement/definitions/metric/volume.rb in ruby-measurement-1.0.0 vs lib/ruby-measurement/definitions/metric/volume.rb in ruby-measurement-1.1.0
- old
+ new
@@ -1,19 +1,89 @@
# encoding: UTF-8
-Measurement.define(:'m³') do |unit|
- unit.alias :m3, :'m^3', :'m*m*m', :'cubic meter', :'cubic meters'
- unit.convert_to(:dm3) { |value| value * 1_000.0 }
- unit.convert_to(:cm3) { |value| value * 1_000_000.0 }
+Measurement.define(:kl) do |unit|
+ unit.alias :kiloliter, :kiloliters
+ unit.convert_to(:hl) { |value| value * 10.0 }
+ unit.convert_to(:dal) { |value| value * 100.0 }
+ unit.convert_to(:l) { |value| value * 1000.0 }
+ unit.convert_to(:dl) { |value| value * 10000.0 }
+ unit.convert_to(:cl) { |value| value * 100000.0 }
+ unit.convert_to(:ml) { |value| value * 1000000.0 }
+ unit.convert_to(:µl) { |value| value * 10000000.0 }
end
-Measurement.define(:'dm³') do |unit|
- unit.alias :dm3, :'dm^3', :'dm*dm*dm', :'cubic decimeter', :'cubic decimeters'
- unit.convert_to(:m3) { |value| value / 1_000.0 }
- unit.convert_to(:cm3) { |value| value * 1_000.0 }
+Measurement.define(:hl) do |unit|
+ unit.alias :hectoliter, :hectoliters
+ unit.convert_to(:kl) { |value| value / 10.0 }
+ unit.convert_to(:dal) { |value| value * 10.0 }
+ unit.convert_to(:l) { |value| value * 100.0 }
+ unit.convert_to(:dl) { |value| value * 1_000.0 }
+ unit.convert_to(:cl) { |value| value * 10_000.0 }
+ unit.convert_to(:ml) { |value| value * 100_000.0 }
+ unit.convert_to(:µl) { |value| value * 1_000_000.0 }
end
-Measurement.define(:'cm³') do |unit|
- unit.alias :cm3, :'cm^3', :'cm*cm*cm', :'cubic centimeter', :'cubic centimeters'
- unit.convert_to(:m3) { |value| value / 1_000_000.0 }
- unit.convert_to(:dm3) { |value| value / 1_000.0 }
+Measurement.define(:dal) do |unit|
+ unit.alias :dekaliter, :dekaliters
+ unit.convert_to(:kl) { |value| value / 100.0 }
+ unit.convert_to(:hl) { |value| value / 10.0 }
+ unit.convert_to(:l) { |value| value * 10.0 }
+ unit.convert_to(:dl) { |value| value * 100.0 }
+ unit.convert_to(:cl) { |value| value * 1_000.0 }
+ unit.convert_to(:ml) { |value| value * 10_000.0 }
+ unit.convert_to(:µl) { |value| value * 100_000.0 }
+end
+
+Measurement.define(:l) do |unit|
+ unit.alias :liter, :liters
+ unit.convert_to(:kl) { |value| value / 1_000.0 }
+ unit.convert_to(:hl) { |value| value / 100.0 }
+ unit.convert_to(:dal) { |value| value / 10.0 }
+ unit.convert_to(:dl) { |value| value * 10.0 }
+ unit.convert_to(:cl) { |value| value * 100.0 }
+ unit.convert_to(:ml) { |value| value * 1_000.0 }
+ unit.convert_to(:µl) { |value| value * 10_000.0 }
+end
+
+Measurement.define(:dl) do |unit|
+ unit.alias :deciliter, :deciliters
+ unit.convert_to(:kl) { |value| value / 10_000.0 }
+ unit.convert_to(:hl) { |value| value / 1_000.0 }
+ unit.convert_to(:dal) { |value| value / 100.0 }
+ unit.convert_to(:l) { |value| value / 10.0 }
+ unit.convert_to(:cl) { |value| value * 10.0 }
+ unit.convert_to(:ml) { |value| value * 100.0 }
+ unit.convert_to(:µl) { |value| value * 1_000.0 }
+end
+
+Measurement.define(:cl) do |unit|
+ unit.alias :centiliter, :centiliters
+ unit.convert_to(:kl) { |value| value / 10_0000.0 }
+ unit.convert_to(:hl) { |value| value / 10_000.0 }
+ unit.convert_to(:dal) { |value| value / 1_000.0 }
+ unit.convert_to(:l) { |value| value / 100.0 }
+ unit.convert_to(:dl) { |value| value / 10.0 }
+ unit.convert_to(:ml) { |value| value * 10.0 }
+ unit.convert_to(:µl) { |value| value * 100.0 }
+end
+
+Measurement.define(:ml) do |unit|
+ unit.alias :milliliter, :milliliters
+ unit.convert_to(:kl) { |value| value / 1_000_000.0 }
+ unit.convert_to(:hl) { |value| value / 100_000.0 }
+ unit.convert_to(:dal) { |value| value / 10_000.0 }
+ unit.convert_to(:l) { |value| value / 1_000.0 }
+ unit.convert_to(:dl) { |value| value / 100.0 }
+ unit.convert_to(:cl) { |value| value / 10.0 }
+ unit.convert_to(:µl) { |value| value * 10.0 }
+end
+
+Measurement.define(:µl) do |unit|
+ unit.alias :microliter, :microliters
+ unit.convert_to(:kl) { |value| value / 10_000_000.0 }
+ unit.convert_to(:hl) { |value| value / 1_000_000.0 }
+ unit.convert_to(:dal) { |value| value / 100_000.0 }
+ unit.convert_to(:l) { |value| value / 10_000.0 }
+ unit.convert_to(:dl) { |value| value / 1_000.0 }
+ unit.convert_to(:cl) { |value| value / 100.0 }
+ unit.convert_to(:ml) { |value| value / 10.0 }
end