Class: Licensed::Reporters::Reporter::Report
- Inherits:
-
Hash
- Object
- Hash
- Licensed::Reporters::Reporter::Report
- Defined in:
- lib/licensed/reporters/reporter.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #all_reports ⇒ Object
- #errors ⇒ Object
-
#initialize(name:, target:) ⇒ Report
constructor
A new instance of Report.
- #reports ⇒ Object
-
#to_h ⇒ Object
Returns the data from the report as a hash.
- #warnings ⇒ Object
Constructor Details
#initialize(name:, target:) ⇒ Report
Returns a new instance of Report.
8 9 10 11 12 |
# File 'lib/licensed/reporters/reporter.rb', line 8 def initialize(name:, target:) super() @name = name @target = target end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/licensed/reporters/reporter.rb', line 6 def name @name end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
7 8 9 |
# File 'lib/licensed/reporters/reporter.rb', line 7 def target @target end |
Instance Method Details
#all_reports ⇒ Object
26 27 28 29 30 |
# File 'lib/licensed/reporters/reporter.rb', line 26 def all_reports result = [] result << self result.push(*reports.flat_map(&:all_reports)) end |
#errors ⇒ Object
18 19 20 |
# File 'lib/licensed/reporters/reporter.rb', line 18 def errors @errors ||= [] end |
#reports ⇒ Object
14 15 16 |
# File 'lib/licensed/reporters/reporter.rb', line 14 def reports @reports ||= [] end |
#to_h ⇒ Object
Returns the data from the report as a hash
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/licensed/reporters/reporter.rb', line 33 def to_h # add name, errors and warnings if they have real data output = {} output["name"] = name unless name.to_s.empty? output["errors"] = errors.dup if errors.any? output["warnings"] = warnings.dup if warnings.any? # merge the hash data from the report. command-specified data always # overwrites local data output.merge(super) end |
#warnings ⇒ Object
22 23 24 |
# File 'lib/licensed/reporters/reporter.rb', line 22 def warnings @warnings ||= [] end |