Class: DryRunReporter
- Inherits:
-
Object
- Object
- DryRunReporter
- Defined in:
- lib/dry_run_reporter.rb
Instance Attribute Summary collapse
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Instance Method Summary collapse
- #add_to_report(key, *values) ⇒ Object
-
#initialize ⇒ DryRunReporter
constructor
A new instance of DryRunReporter.
- #print_report ⇒ Object
Constructor Details
#initialize ⇒ DryRunReporter
Returns a new instance of DryRunReporter.
6 7 8 |
# File 'lib/dry_run_reporter.rb', line 6 def initialize @report = {} end |
Instance Attribute Details
#report ⇒ Object (readonly)
Returns the value of attribute report.
4 5 6 |
# File 'lib/dry_run_reporter.rb', line 4 def report @report end |
Instance Method Details
#add_to_report(key, *values) ⇒ Object
10 11 12 13 14 |
# File 'lib/dry_run_reporter.rb', line 10 def add_to_report(key, *values) report[key] = [] if report[key].nil? report[key].concat(values) report[key].uniq! end |
#print_report ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dry_run_reporter.rb', line 16 def print_report if @report.to_a.map(&:second).flatten.empty? puts 'Dry run active. No data would be removed in normal run.' else puts 'Dry run active. The following data would be removed in normal run:' @report.to_a.map(&:first).each do |symbol| print_report_line(symbol) end end end |