Sha256: 5679a81203faf316932fbe4f48369cdf475e746e471ad3fa8931b4bfe3b69645

Contents?: true

Size: 514 Bytes

Versions: 2

Compression:

Stored size: 514 Bytes

Contents

require "ansi/progressbar"

module PbSyringe
  class AnsiProgressbarUnit < ProgressUnit
    attr_reader :progressbar
    def start(**options)
      $stdout.sync = true
      $stderr.sync = true
      @progressbar = ANSI::Progressbar.new(options[:label], options[:total])
    end

    def increment(count)
      @progressbar.inc(count) if @progressbar
    end

    def finish
      @progressbar.finish if @progressbar
      @progressbar = nil
      $stderr.sync = false
      $stdout.sync = false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pb_syringe-0.1.1 lib/pb_syringe/ansi_progressbar_unit.rb
pb_syringe-0.1.0 lib/pb_syringe/ansi_progressbar_unit.rb