lib/progress.rb in progress-0.0.3 vs lib/progress.rb in progress-0.0.4
- old
+ new
@@ -2,11 +2,11 @@
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'singleton'
class Progress
- VERSION = '0.0.3'
+ VERSION = '0.0.4'
include Singleton
# start progress indication
# ==== Procedural example
@@ -15,10 +15,16 @@
# Progress.stop
# ==== Block example
# Progress.start('Test', 1000) do
# 1000.times{ Progress.step }
# end
+ # ==== Step must not always be one
+ # Progress.start('Test', 10) do
+ # (1..10).to_a.each_slice do |slice|
+ # Progress.step(slice.length)
+ # end
+ # end
# ==== Enclosed block example
# [1, 2, 3].each_with_progress('1 2 3') do |one_of_1_2_3|
# 10.times_with_progress('10') do |one_of_10|
# sleep(0.001)
# end
@@ -30,12 +36,12 @@
yield
stop
end
end
- def self.step
- levels[-1].step
+ def self.step(steps = 1)
+ levels[-1].step(steps)
print_message
end
def self.stop
levels.pop.stop
@@ -56,11 +62,11 @@
def start # :nodoc:
self.message = '.' * 6
end
- def step # :nodoc:
- @current += 1
+ def step(steps) # :nodoc:
+ @current += steps
self.message = percent
end
def stop # :nodoc:
self.message = percent