Class: Derrick::CLI::ProgressDisplay
- Inherits:
-
Object
- Object
- Derrick::CLI::ProgressDisplay
- Defined in:
- lib/derrick/cli.rb
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(progress, output) ⇒ ProgressDisplay
constructor
A new instance of ProgressDisplay.
- #render ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(progress, output) ⇒ ProgressDisplay
Returns a new instance of ProgressDisplay.
10 11 12 13 14 |
# File 'lib/derrick/cli.rb', line 10 def initialize(progress, output) @progress = progress @output = output @last_output_size = 0 end |
Instance Method Details
#clear ⇒ Object
23 24 25 |
# File 'lib/derrick/cli.rb', line 23 def clear @output.print "\b" * @last_output_size end |
#render ⇒ Object
16 17 18 19 20 21 |
# File 'lib/derrick/cli.rb', line 16 def render clear = "collected: #{@progress.collected}/#{@progress.total} fetched: #{@progress.fetched}/#{@progress.total}" @last_output_size = .size @output.print end |
#start ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/derrick/cli.rb', line 27 def start @thread = Thread.new do loop do render sleep 1 end end end |
#stop ⇒ Object
36 37 38 39 |
# File 'lib/derrick/cli.rb', line 36 def stop @thread.kill clear end |