Иван обнови решението на 17.10.2016 15:10 (преди около 9 години)
+MY_HASH =
+  {
+    'water' => [0, 100], 'ethanol' => [-114, 78.37],
+    'gold' => [1064, 2700], 'silver' => [961.8, 2162],
+    'copper' => [1085, 2567]
+  }.freeze
+
+def convert_between_temperature_units(temp, from, to)
+  if temp.is_a?Numeric
+    if 'C' == from
+      convert_from_celsius(temp, to)
+    elsif 'F' == from
+      convert_from_farenheit(temp, to)
+    elsif 'K' == from
+      convert_from_kelvin(temp, to)
+    end
+  else puts 'Wrong parameters!'
+  end
+end
+
+def convert_from_celsius(temp, to)
+  if 'F' == to
+    temp * 1.8 + 32
+  elsif 'K' == to
+    temp + 273.15
+  elsif 'C' == to
+    temp
+  else
+    puts 'Wrong parameters!'
+  end
+end
+
+def convert_from_kelvin(temp, to)
+  if 'C' == to
+    temp - 273.15
+  elsif 'F' == to
+    (temp * 1.8) - 459.67
+  else
+    puts 'Wrong parameters!'
+  end
+end
+
+def convert_from_farenheit(temp, to)
+  if 'C' == to
+    (temp - 32) / 1.8
+  elsif 'K' == to
+    (temp + 459.67) * 0.5555
+  else
+    puts 'Wrong parameters!'
+  end
+end
+
+def melting_point_of_substance(substance, metric)
+  if !MY_HASH[substance].nil?
+    convert_between_temperature_units(MY_HASH[substance][0], 'C', metric)
+  else puts 'Wrong parameters!'
+  end
+end
+
+def boiling_point_of_substance(substance, metric)
+  if !MY_HASH[substance].nil?
+    convert_between_temperature_units(MY_HASH[substance][1], 'C', metric)
+  else puts 'Wrong parameters!'
+  end
+end
+
+puts convert_between_temperature_units(5, 'C', 'K')
+puts melting_point_of_substance('gold', 'K')
+puts boiling_point_of_substance('gold', 'K')
