Class: Rigor::Analysis::Result
- Inherits:
-
Object
- Object
- Rigor::Analysis::Result
- Defined in:
- lib/rigor/analysis/result.rb
Instance Attribute Summary collapse
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
- #error_count ⇒ Object
-
#initialize(diagnostics: [], stats: nil) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(diagnostics: [], stats: nil) ⇒ Result
Returns a new instance of Result.
13 14 15 16 |
# File 'lib/rigor/analysis/result.rb', line 13 def initialize(diagnostics: [], stats: nil) @diagnostics = diagnostics @stats = stats end |
Instance Attribute Details
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
6 7 8 |
# File 'lib/rigor/analysis/result.rb', line 6 def diagnostics @diagnostics end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
6 7 8 |
# File 'lib/rigor/analysis/result.rb', line 6 def stats @stats end |
Instance Method Details
#error_count ⇒ Object
22 23 24 |
# File 'lib/rigor/analysis/result.rb', line 22 def error_count diagnostics.count(&:error?) end |
#success? ⇒ Boolean
18 19 20 |
# File 'lib/rigor/analysis/result.rb', line 18 def success? diagnostics.none?(&:error?) end |
#to_h ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/rigor/analysis/result.rb', line 26 def to_h hash = { "success" => success?, "error_count" => error_count, "diagnostics" => diagnostics.map(&:to_h) } hash["stats"] = @stats.to_h if @stats hash end |