Skip to content

Commit

Permalink
Add :current and :total as possible format arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peeja committed Nov 20, 2009
1 parent 4a23411 commit 7c5f657
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/multi_progress_bar/bar.rb
Expand Up @@ -15,6 +15,9 @@ module MultiProgressBar
#
# See the +ruby-progressbar+ gem (http://0xcc.net/ruby-progressbar/index.html.en)
# for more details.
#
# MultiProgressBar::Bar makes two additional format arguments available: :current
# and :total. These display the current and total values respectively.
class Bar < DelegateClass(BarRenderer)
# Create a new Bar with a +title+ and a +total+ value.
def initialize(title, total)
Expand Down
8 changes: 8 additions & 0 deletions lib/multi_progress_bar/bar_renderer.rb
Expand Up @@ -9,6 +9,14 @@ def initialize(title, total, width, &block)
super(title, total, @buffer)
end

def fmt_current
@current
end

def fmt_total
@total
end

def show
super
@block.call(@buffer.string)
Expand Down

0 comments on commit 7c5f657

Please sign in to comment.