Module: Measured::ConversionTable
- Extended by:
- ConversionTable
- Included in:
- ConversionTable
- Defined in:
- lib/measured/conversion_table.rb
Instance Method Summary collapse
Instance Method Details
#build(units) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/measured/conversion_table.rb', line 4 def build(units) table = {} units.map{|u| u.name}.each do |to_unit| to_table = {to_unit => BigDecimal("1")} table.each do |from_unit, from_table| to_table[from_unit] = find_conversion(units, to: from_unit, from: to_unit) from_table[to_unit] = find_conversion(units, to: to_unit, from: from_unit) end table[to_unit] = to_table end table end |