Class: ProgressBar
- Inherits:
-
Object
- Object
- ProgressBar
- Defined in:
- lib/doro/progressbar.rb
Instance Method Summary collapse
-
#initialize(title, max_progress) ⇒ ProgressBar
constructor
A new instance of ProgressBar.
- #start ⇒ Object
Constructor Details
#initialize(title, max_progress) ⇒ ProgressBar
Returns a new instance of ProgressBar.
6 7 8 9 10 11 12 |
# File 'lib/doro/progressbar.rb', line 6 def initialize(title, max_progress) @progress = 0 @max_progress = max_progress @title = title @start_time = Time.now @interrupt = false end |
Instance Method Details
#start ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/doro/progressbar.rb', line 14 def start Signal.trap("INT") { @interrupt = true } while (@progress <= @max_progress && @interrupt == false ) render_progress @progress += 1 yield sleep 1 end print("\r") display_notification end |