Class: Eta::ProgressBar
- Inherits:
-
Object
- Object
- Eta::ProgressBar
- Defined in:
- lib/eta.rb
Instance Method Summary collapse
- #draw(current, total) ⇒ Object
- #draw_spinner ⇒ Object
-
#initialize ⇒ ProgressBar
constructor
A new instance of ProgressBar.
Constructor Details
#initialize ⇒ ProgressBar
Returns a new instance of ProgressBar.
8 9 10 |
# File 'lib/eta.rb', line 8 def initialize @spinner = %w{/ - \\}.cycle end |
Instance Method Details
#draw(current, total) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/eta.rb', line 18 def draw current, total print "\r" print "[" progress = calculate_progress(current, total) not_progress = screen_width - progress - 2 progress.times { print "#" } not_progress.times { print " " } print "]" end |
#draw_spinner ⇒ Object
12 13 14 15 16 |
# File 'lib/eta.rb', line 12 def draw_spinner print "\r" print @spinner.next print "\r" end |