Joined March 2012
·

brian wisti

Seattle, WA
·
·
·

Posted to Rake Progress Bar over 1 year ago

This was useful to me in a project just now! I made one small change, adding a parameter to be used as a descriptive string:

class ProgressBar

  def initialize(total, description)
    @description  = description
    @total  = total
    @counter = 1
  end

  def increment
    complete = sprintf("%#.2f%", ((@counter.to_f / @total.to_f) * 100))
    print "\r\e[0K#{@description} #{@counter}/#{@total} (#{complete})"
    @counter += 1
  end

end
Achievements
89 Karma
3,192 Total ProTip Views