lib/progress_bar.rb in progress_bar-1.0.1 vs lib/progress_bar.rb in progress_bar-1.0.2
- old
+ new
@@ -1,19 +1,23 @@
require 'options'
require 'highline'
class ProgressBar
+ Error = Class.new(StandardError)
+ ArgumentError = Class.new(Error)
attr_accessor :count, :max, :meters
def initialize(*args)
@count = 0
@max = 100
@meters = [:bar, :counter, :percentage, :elapsed, :eta, :rate]
@max = args.shift if args.first.is_a? Numeric
+ raise ArgumentError, "Max must be a positive integer" unless @max > 0
+
@meters = args unless args.empty?
@last_write = ::Time.at(0)
@start = ::Time.now