Sha256: 67584021d910e56d77777503cbad1f37f9b2961f9e93c3f59b25fd5d1eb0106f

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 Bytes

Contents

module MultiProgressBar
  class BarRenderer < ProgressBar  #:nodoc:
    attr_writer :total
    attr_accessor :width

    def initialize(title, total, width, &block)
      @block = block
      @buffer = StringIO.new
      @width = width
      super(title, total, @buffer)
    end

    def fmt_current
      @current
    end

    def fmt_total
      @total
    end

    def show
      super
      @block.call(@buffer.string)
      @buffer.string = ""
    end

    def title=(new_title)
      @title = new_title
      show
    end

    def get_width
      @width
    end

    def restart
      set(0)
      @start_time = Time.now
      @previous_time = @start_time
    end

    def do_percentage
      if @current.zero?
        0
      else
        super
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
ruby-multi-progressbar-1.0.0 lib/ruby-multi-progressbar/bar_renderer.rb
multi_progress_bar-0.3.0 lib/multi_progress_bar/bar_renderer.rb