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.
8 9 10 11 12 |
# File 'lib/derrick/cli.rb', line 8 def initialize(progress, output) @progress = progress @output = output @last_output_size = 0 end |
Instance Method Details
#clear ⇒ Object
21 22 23 |
# File 'lib/derrick/cli.rb', line 21 def clear @output.print "\b" * @last_output_size end |
#render ⇒ Object
14 15 16 17 18 19 |
# File 'lib/derrick/cli.rb', line 14 def render clear = "collected: #{@progress.collected}/#{@progress.total} fetched: #{@progress.fetched}/#{@progress.total}" @last_output_size = .size @output.print end |
#start ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/derrick/cli.rb', line 25 def start @thread = Thread.new do loop do render sleep 1 end end end |
#stop ⇒ Object
34 35 36 37 |
# File 'lib/derrick/cli.rb', line 34 def stop @thread.kill clear end |