Class: Ask::Eval::Judge::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/ask/eval/judge.rb

Overview

The verdict from a judge evaluation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(passed:, score:, reason:, cost: nil) ⇒ Result

Returns a new instance of Result.



55
56
57
58
59
60
61
# File 'lib/ask/eval/judge.rb', line 55

def initialize(passed:, score:, reason:, cost: nil)
  @passed = passed
  @score = score
  @reason = reason
  @cost = cost
  freeze
end

Instance Attribute Details

#costHash? (readonly)

Returns cost breakdown if tracking was enabled.

Returns:

  • (Hash, nil)

    cost breakdown if tracking was enabled



53
54
55
# File 'lib/ask/eval/judge.rb', line 53

def cost
  @cost
end

#passedBoolean (readonly)

Returns whether the output passed the check.

Returns:

  • (Boolean)

    whether the output passed the check



44
45
46
# File 'lib/ask/eval/judge.rb', line 44

def passed
  @passed
end

#reasonString (readonly)

Returns explanation from the judge.

Returns:

  • (String)

    explanation from the judge



50
51
52
# File 'lib/ask/eval/judge.rb', line 50

def reason
  @reason
end

#scoreFloat (readonly)

Returns score from 0.0 to 1.0.

Returns:

  • (Float)

    score from 0.0 to 1.0



47
48
49
# File 'lib/ask/eval/judge.rb', line 47

def score
  @score
end

Instance Method Details

#inspectString

Returns:

  • (String)


69
70
71
72
# File 'lib/ask/eval/judge.rb', line 69

def inspect
  status = @passed ? "PASS" : "FAIL"
  "#<Judge::Result #{status} score=#{@score} reason=#{@reason[0..80].inspect}>"
end

#to_hHash

Returns:

  • (Hash)


64
65
66
# File 'lib/ask/eval/judge.rb', line 64

def to_h
  { passed: @passed, score: @score, reason: @reason, cost: @cost }.compact
end