Class: Evilution::Reporter::ProgressBar Private
- Inherits:
-
Object
- Object
- Evilution::Reporter::ProgressBar
- Defined in:
- lib/evilution/reporter/progress_bar.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #completed ⇒ Object readonly private
- #killed ⇒ Object readonly private
- #survived ⇒ Object readonly private
- #total ⇒ Object readonly private
- #width ⇒ Object readonly private
Class Method Summary collapse
- .tty?(io) ⇒ Boolean private
Instance Method Summary collapse
- #finish ⇒ Object private
-
#initialize(total:, output: $stdout, width: 30) ⇒ ProgressBar
constructor
private
A new instance of ProgressBar.
- #render ⇒ Object private
- #tick(status:) ⇒ Object private
Constructor Details
#initialize(total:, output: $stdout, width: 30) ⇒ ProgressBar
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ProgressBar.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/evilution/reporter/progress_bar.rb', line 8 def initialize(total:, output: $stdout, width: 30) @total = total @output = output @width = width @completed = 0 @killed = 0 @survived = 0 @tty = self.class.tty?(output) @start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) end |
Instance Attribute Details
#completed ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/evilution/reporter/progress_bar.rb', line 6 def completed @completed end |
#killed ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/evilution/reporter/progress_bar.rb', line 6 def killed @killed end |
#survived ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/evilution/reporter/progress_bar.rb', line 6 def survived @survived end |
#total ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/evilution/reporter/progress_bar.rb', line 6 def total @total end |
#width ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/evilution/reporter/progress_bar.rb', line 6 def width @width end |
Class Method Details
.tty?(io) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 |
# File 'lib/evilution/reporter/progress_bar.rb', line 40 def self.tty?(io) io.respond_to?(:tty?) && io.tty? end |
Instance Method Details
#finish ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 |
# File 'lib/evilution/reporter/progress_bar.rb', line 35 def finish render @output.print("\n") if @tty end |
#render ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 31 32 33 |
# File 'lib/evilution/reporter/progress_bar.rb', line 26 def render line = "#{} #{stats_string} | #{time_string}" if @tty @output.print("\r#{line}") else @output.puts(line) end end |
#tick(status:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 |
# File 'lib/evilution/reporter/progress_bar.rb', line 19 def tick(status:) @completed += 1 @killed += 1 if status == :killed @survived += 1 if status == :survived render end |