class Infobar::Display
def layout_bar(message, counter)
def layout_bar(message, counter) cols = columns todo = message.to_str.center cols, replace_character if counter.total > 0 max_done_length = counter.progressed * cols total_done = 0 counter.as.each_with_index do |(name, count), i| style_name = name.to_s.to_sym done_fill = as_styles[style_name].fetch(:done_fill) { @style[:done_fill] } done_fg_color = as_styles[style_name].fetch(:done_fg_color) { @style[:done_fg_color] } done_bg_color = as_styles[style_name].fetch(:done_bg_color) { @style[:done_bg_color] } as_progressed = count / counter.total.to_f as_done = as_progressed * cols total_done += as_done if counter.done? && i == counter.as.size - 1 && total_done <= max_done_length done = todo.dup todo = '' else done = todo.slice!(0, as_done) end done.gsub!(replace_character, done_fill[0]) output << color(done_fg_color, on_color(done_bg_color, done)) end end if todo.present? todo.gsub!(replace_character, @style[:todo_fill][0]) output << color(@style[:todo_fg_color], on_color(@style[:todo_bg_color], todo)) end end