class Cxxproject::Utils::Progress
Public Class Methods
new(form, size)
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 4 def initialize(form, size) @width = size[0] initialize_progress(form, size) initialize_title(form, size) max = 100 end
Public Instance Methods
format_progress()
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 50 def format_progress total = (percentage * @width.to_f).to_i text = "#" * total @progress.text = text @progress.repaint_all(true) end
format_title()
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 57 def format_title format = "%3d%% - worked on %s " @title.text = sprintf(format, (percentage*100).to_i, @title_text) @title.repaint_all(true) end
inc(i)
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 40 def inc(i) @current += i format_title format_progress end
initialize_progress(form, size)
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 11 def initialize_progress(form, size) @progress = Label.new form do name 'progress' row size[1]-1 col 0 width size[0] height 1 end @progress.display_length(@width) @progress.text = ' '*@width end
initialize_title(form, size)
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 23 def initialize_title(form, size) @title = Label.new form do name 'title' row size[1]-2 col 0 width size[0] height 1 end @title.display_length(@widget) @title.text = 'Idle' end
max=(f)
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 63 def max=(f) @max = f.to_f @current = 0.0 format_progress format_title end
percentage()
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 46 def percentage return @current.to_f / @max.to_f end
title=(t)
click to toggle source
# File lib/cxxproject/utils/rbcurse_progress.rb, line 35 def title=(t) @title_text = t format_title end