Class: Retab::AssertionSpec

Inherits:
Types::BaseModel show all
Defined in:
lib/retab/workflow_tests/assertion_spec.rb

Constant Summary collapse

HASH_ATTRS =
{
  id: :id,
  target: :target,
  condition: :condition,
  label: :label
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

#inspect, normalize, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ AssertionSpec

Returns a new instance of AssertionSpec.



21
22
23
24
25
26
27
# File 'lib/retab/workflow_tests/assertion_spec.rb', line 21

def initialize(json)
  hash = self.class.normalize(json)
  @id = hash[:id]
  @target = hash[:target] ? Retab::OutputTarget.new(hash[:target]) : nil
  @condition = hash[:condition] ? (case hash[:condition][:kind] when "all_items_match" then Retab::AllItemsMatchCondition.new(hash[:condition]) when "any_item_matches" then Retab::AnyItemMatchesCondition.new(hash[:condition]) when "array_contains" then Retab::ArrayContainsCondition.new(hash[:condition]) when "between" then Retab::BetweenCondition.new(hash[:condition]) when "ends_with" then Retab::EndsWithCondition.new(hash[:condition]) when "json_schema_valid" then Retab::JsonSchemaValidCondition.new(hash[:condition]) when "length_compare" then Retab::LengthCompareCondition.new(hash[:condition]) when "llm_judged_as" then Retab::LlmJudgedAsCondition.new(hash[:condition]) when "llm_not_judged_as" then Retab::LlmNotJudgedAsCondition.new(hash[:condition]) when "not_contains" then Retab::NotContainsCondition.new(hash[:condition]) when "not_equals" then Retab::NotEqualsCondition.new(hash[:condition]) when "not_exists" then Retab::NotExistsCondition.new(hash[:condition]) when "number_compare" then Retab::NumberCompareCondition.new(hash[:condition]) when "object_contains" then Retab::ObjectContainsCondition.new(hash[:condition]) when "similarity_gte" then Retab::SimilarityGteCondition.new(hash[:condition]) else hash[:condition] end) : nil
  @label = hash[:label]
end

Instance Attribute Details

#conditionObject

Returns the value of attribute condition.



15
16
17
# File 'lib/retab/workflow_tests/assertion_spec.rb', line 15

def condition
  @condition
end

#idObject

Returns the value of attribute id.



15
16
17
# File 'lib/retab/workflow_tests/assertion_spec.rb', line 15

def id
  @id
end

#labelObject

Returns the value of attribute label.



15
16
17
# File 'lib/retab/workflow_tests/assertion_spec.rb', line 15

def label
  @label
end

#targetObject

Returns the value of attribute target.



15
16
17
# File 'lib/retab/workflow_tests/assertion_spec.rb', line 15

def target
  @target
end