def bar(perc, width, start = "[", _end = "]", u = "#", mu = "+", e = "-") r = "" q = perc.to_f / 100.0 * width.to_f p = (q - q.to_i.to_f) > 0.0 ? true : false r += start q.to_i.times { r += u } p ? r += mu : nil (width - q).to_i.times { r += e } r += _end r end w = 25 puts " 0% #{bar(0, w)}" puts puts " 25% #{bar(25, w, "<", ">", "O", "o", ".")}" puts puts " 50% #{bar(50, w, "{", "}", "=", "-", ".")}" puts puts " 75% #{bar(75, w, "[", "]", "#", "*", " ")}" puts puts "100% #{bar(100, w, "<", ">", "*", "'", "-")}" puts