class WeightConverter
Public Instance Methods
colorize(string, color)
click to toggle source
# File lib/weight_converter.rb, line 37 def colorize(string, color) string.colorize(color) end
convert(number, from, to, color)
click to toggle source
# File lib/weight_converter.rb, line 25 def convert(number, from, to, color) return colorize(convert_g_to(convert_to_g(number.to_f, from), to).to_s, color) end
convert_g_to(number, to)
click to toggle source
# File lib/weight_converter.rb, line 33 def convert_g_to(number, to) return number / @@weights[to] end
convert_to_g(number, from)
click to toggle source
# File lib/weight_converter.rb, line 29 def convert_to_g(number, from) return number * @@weights[from] end