Class: Uniword::Batch::Operation::Report
- Inherits:
-
Object
- Object
- Uniword::Batch::Operation::Report
- Defined in:
- lib/uniword/batch/operation/report.rb
Overview
Aggregated report for a batch run.
Instance Attribute Summary collapse
-
#operation_name ⇒ Object
readonly
Returns the value of attribute operation_name.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #add(result) ⇒ void
-
#all_success? ⇒ Boolean
True when every file succeeded.
-
#count ⇒ Integer
Total file count processed.
-
#failed_paths ⇒ Array<String>
List of failed file paths.
-
#failure_count ⇒ Integer
Count of failed files.
-
#initialize(operation_name:) ⇒ Report
constructor
A new instance of Report.
-
#success_count ⇒ Integer
Count of successful files.
-
#total_metric ⇒ Integer
Sum of per-file metrics (e.g. total repairs applied).
Constructor Details
#initialize(operation_name:) ⇒ Report
Returns a new instance of Report.
11 12 13 14 |
# File 'lib/uniword/batch/operation/report.rb', line 11 def initialize(operation_name:) @operation_name = operation_name @results = [] end |
Instance Attribute Details
#operation_name ⇒ Object (readonly)
Returns the value of attribute operation_name.
8 9 10 |
# File 'lib/uniword/batch/operation/report.rb', line 8 def operation_name @operation_name end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
8 9 10 |
# File 'lib/uniword/batch/operation/report.rb', line 8 def results @results end |
Instance Method Details
#add(result) ⇒ void
This method returns an undefined value.
18 19 20 |
# File 'lib/uniword/batch/operation/report.rb', line 18 def add(result) @results << result end |
#all_success? ⇒ Boolean
True when every file succeeded.
53 54 55 |
# File 'lib/uniword/batch/operation/report.rb', line 53 def all_success? @results.all?(&:success?) end |
#count ⇒ Integer
Total file count processed.
25 26 27 |
# File 'lib/uniword/batch/operation/report.rb', line 25 def count @results.length end |
#failed_paths ⇒ Array<String>
List of failed file paths.
60 61 62 |
# File 'lib/uniword/batch/operation/report.rb', line 60 def failed_paths @results.reject(&:success?).map(&:path) end |
#failure_count ⇒ Integer
Count of failed files.
39 40 41 |
# File 'lib/uniword/batch/operation/report.rb', line 39 def failure_count @results.count { |r| !r.success? } end |
#success_count ⇒ Integer
Count of successful files.
32 33 34 |
# File 'lib/uniword/batch/operation/report.rb', line 32 def success_count @results.count(&:success?) end |
#total_metric ⇒ Integer
Sum of per-file metrics (e.g. total repairs applied).
46 47 48 |
# File 'lib/uniword/batch/operation/report.rb', line 46 def total_metric @results.sum(&:metric) end |