lib/progress.rb in progress-0.0.8.1 vs lib/progress.rb in progress-0.0.9.0
- old
+ new
@@ -29,22 +29,23 @@
# end
# ==== To output progress as lines (not trying to stay on line)
# Progress.start('Test', 1000, :lines => true) do
# 1000.times{ Progress.step }
# end
- def self.start(name, total = 1, options = {})
- levels << new(name, total, levels.length, options)
+ def self.start(title, total = 1, options = {})
+ levels << new(title, total, levels.length, options)
print_message
if block_given?
result = yield
stop
result
end
end
- def initialize(name, total, level, options) # :nodoc:
- @name = name + ': %s'
+ attr_reader :message, :options
+ def initialize(title, total, level, options) # :nodoc:
+ @title = title + ': %s'
@total = total
@level = level
@options = options
@current = 0
start
@@ -61,27 +62,19 @@
def stop # :nodoc:
self.message = percent
end
- def message # :nodoc:
- @message
- end
-
- def options # :nodoc:
- @options
- end
-
protected
def percent
'%5.1f%%' % (@current * 100.0 / @total)
end
def message=(s)
formatted = s.ljust(6)[0, 6]
- @message = @name % formatted
+ @message = @title % formatted
end
module ClassMethods
def step(steps = 1)
levels[-1].step(steps)
@@ -91,11 +84,11 @@
def stop
levels.pop.stop
@io.puts if levels.empty?
end
- def io=(io) # :nodoc:
+ def io=(io)
@io = io
end
protected
@@ -115,8 +108,10 @@
@levels ||= []
end
end
extend ClassMethods
end
+
+require 'progress/with_progress'
require 'progress/enumerable'
require 'progress/integer'