Sha256: 1c3cccaaa9fb8f215bd9183abbbaf3b0a287fd474e6fddcf4cb32d1994cf099f

Contents?: true

Size: 755 Bytes

Versions: 2

Compression:

Stored size: 755 Bytes

Contents

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

    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 & 1 rubygems

Version Path
multi_progress_bar-0.2.0 lib/multi_progress_bar/bar_renderer.rb
multi_progress_bar-0.1.3 lib/multi_progress_bar/bar_renderer.rb