Class: Yard::Lint::Formatters::Progress
- Inherits:
-
Object
- Object
- Yard::Lint::Formatters::Progress
- Defined in:
- lib/yard/lint/formatters/progress.rb
Overview
Simple progress formatter that shows which validator is running Similar to RuboCop’s progress display
Instance Method Summary collapse
-
#finish ⇒ Object
Finish progress display.
-
#initialize(output = $stdout) ⇒ Progress
constructor
Initialize progress formatter.
-
#start(total) ⇒ Object
Start progress display.
-
#update(current, validator_name) ⇒ Object
Update progress with current validator.
Constructor Details
#initialize(output = $stdout) ⇒ Progress
Initialize progress formatter
12 13 14 15 16 |
# File 'lib/yard/lint/formatters/progress.rb', line 12 def initialize(output = $stdout) @output = output @total = 0 @current = 0 end |
Instance Method Details
#finish ⇒ Object
Finish progress display
43 44 45 46 |
# File 'lib/yard/lint/formatters/progress.rb', line 43 def finish @output.print "\r\e[K" # Clear the progress line @output.flush end |
#start(total) ⇒ Object
Start progress display
20 21 22 23 24 |
# File 'lib/yard/lint/formatters/progress.rb', line 20 def start(total) @total = total @current = 0 @output.print "Inspecting with #{total} validators\n" end |
#update(current, validator_name) ⇒ Object
Update progress with current validator
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yard/lint/formatters/progress.rb', line 29 def update(current, validator_name) @current = current # Clear line and show progress @output.print "\r\e[K" # Clear line @output.print format( '[%<current>d/%<total>d] %<name>s', current: current, total: @total, name: validator_name ) @output.flush end |