Class: RSpec::FlakeClassifier::Classify::Result
- Inherits:
-
Object
- Object
- RSpec::FlakeClassifier::Classify::Result
- Defined in:
- lib/rspec/flake/classifier/classify/result.rb,
sig/rspec/flake/classifier.rbs
Instance Attribute Summary collapse
-
#evidence ⇒ Array[String]
readonly
Returns the value of attribute evidence.
-
#labels ⇒ Array[untyped]
readonly
Returns the value of attribute labels.
-
#status ⇒ String
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #flaky? ⇒ Boolean
-
#initialize(status:, labels:, evidence: []) ⇒ Result
constructor
A new instance of Result.
- #primary_label ⇒ Object
- #to_h ⇒ Hash[String, untyped]
Constructor Details
#initialize(status:, labels:, evidence: []) ⇒ Result
Returns a new instance of Result.
20 21 22 23 24 |
# File 'lib/rspec/flake/classifier/classify/result.rb', line 20 def initialize(status:, labels:, evidence: []) @status = status.to_s @labels = labels.sort_by { |label| -label.confidence.to_f } @evidence = evidence end |
Instance Attribute Details
#evidence ⇒ Array[String] (readonly)
Returns the value of attribute evidence.
18 19 20 |
# File 'lib/rspec/flake/classifier/classify/result.rb', line 18 def evidence @evidence end |
#labels ⇒ Array[untyped] (readonly)
Returns the value of attribute labels.
18 19 20 |
# File 'lib/rspec/flake/classifier/classify/result.rb', line 18 def labels @labels end |
#status ⇒ String (readonly)
Returns the value of attribute status.
18 19 20 |
# File 'lib/rspec/flake/classifier/classify/result.rb', line 18 def status @status end |
Instance Method Details
#flaky? ⇒ Boolean
30 31 32 |
# File 'lib/rspec/flake/classifier/classify/result.rb', line 30 def flaky? status == "flaky" || !labels.empty? end |
#primary_label ⇒ Object
26 27 28 |
# File 'lib/rspec/flake/classifier/classify/result.rb', line 26 def primary_label labels.first end |
#to_h ⇒ Hash[String, untyped]
34 35 36 37 38 39 40 |
# File 'lib/rspec/flake/classifier/classify/result.rb', line 34 def to_h { "status" => status, "labels" => labels.map(&:to_h), "evidence" => evidence } end |