Class: PromptCanary::RollbackRule
- Inherits:
-
Object
- Object
- PromptCanary::RollbackRule
- Defined in:
- lib/prompt_canary/rollback_rule.rb
Instance Attribute Summary collapse
-
#comparator ⇒ Object
readonly
Returns the value of attribute comparator.
-
#metric ⇒ Object
readonly
Returns the value of attribute metric.
-
#threshold ⇒ Object
readonly
Returns the value of attribute threshold.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
-
#initialize(metric:, threshold:, comparator:, window:) ⇒ RollbackRule
constructor
A new instance of RollbackRule.
- #violated_by?(value) ⇒ Boolean
Constructor Details
#initialize(metric:, threshold:, comparator:, window:) ⇒ RollbackRule
Returns a new instance of RollbackRule.
7 8 9 10 11 12 13 |
# File 'lib/prompt_canary/rollback_rule.rb', line 7 def initialize(metric:, threshold:, comparator:, window:) @metric = metric @threshold = threshold @comparator = comparator @window = window freeze end |
Instance Attribute Details
#comparator ⇒ Object (readonly)
Returns the value of attribute comparator.
5 6 7 |
# File 'lib/prompt_canary/rollback_rule.rb', line 5 def comparator @comparator end |
#metric ⇒ Object (readonly)
Returns the value of attribute metric.
5 6 7 |
# File 'lib/prompt_canary/rollback_rule.rb', line 5 def metric @metric end |
#threshold ⇒ Object (readonly)
Returns the value of attribute threshold.
5 6 7 |
# File 'lib/prompt_canary/rollback_rule.rb', line 5 def threshold @threshold end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
5 6 7 |
# File 'lib/prompt_canary/rollback_rule.rb', line 5 def window @window end |
Instance Method Details
#violated_by?(value) ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/prompt_canary/rollback_rule.rb', line 15 def violated_by?(value) case comparator when :greater_than then value > threshold when :less_than then value < threshold end end |