Sha256: e57a7d5eacc09dc2b3e5cd39ac1c7e7175781429310f231eda47b80eafe37a5d

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

Stored size: 776 Bytes

Contents

#!/usr/bin/env ruby

require 'rubygems'

$LOAD_PATH.unshift File.dirname(__FILE__)+"/../lib"
require 'multi_progress_bar'


begin
  MultiProgressBar.start

  # Demo.
  make_machine_bar = lambda { MultiProgressBar::Bar.new("(Waiting...)", 100) }
  machine_bars = [make_machine_bar[], make_machine_bar[]]
  total = MultiProgressBar::TotalBar.new("-Total-")

  machine_names = ["bleeker", "montrose"]

  until machine_bars.all? { |bar| bar.current == bar.total }
    sleep(0.1)

    # Simulate machines becoming available.
    machine_bars.each do |bar|
      if bar.title == "(Waiting...)"
        bar.title = machine_names.pop if rand(10) == 0
      else
        bar.inc(rand(10))
      end
    end

    MultiProgressBar.log(rand(2000))
  end
ensure
  MultiProgressBar.end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
multi_progress_bar-0.1.0 examples/example.rb
multi_progress_bar-0.0.0 examples/example.rb