Class: Licensed::Report
- Inherits:
-
Hash
- Object
- Hash
- Licensed::Report
- Defined in:
- lib/licensed/report.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.
7 8 9 10 11 |
# File 'lib/licensed/report.rb', line 7 def initialize(name:, target:) super() @name = name @target = target end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/licensed/report.rb', line 5 def name @name end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'lib/licensed/report.rb', line 6 def target @target end |
Instance Method Details
#all_reports ⇒ Object
25 26 27 28 29 |
# File 'lib/licensed/report.rb', line 25 def all_reports result = [] result << self result.push(*reports.flat_map(&:all_reports)) end |
#errors ⇒ Object
17 18 19 |
# File 'lib/licensed/report.rb', line 17 def errors @errors ||= [] end |
#reports ⇒ Object
13 14 15 |
# File 'lib/licensed/report.rb', line 13 def reports @reports ||= [] end |
#to_h ⇒ Object
Returns the data from the report as a hash
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/licensed/report.rb', line 32 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
21 22 23 |
# File 'lib/licensed/report.rb', line 21 def warnings @warnings ||= [] end |