Class: Mindee::Product::Generated::GeneratedV1Document
- Inherits:
-
GeneratedV1Prediction
- Object
- Mindee::Parsing::Common::Prediction
- GeneratedV1Prediction
- Mindee::Product::Generated::GeneratedV1Document
- Includes:
- Mindee::Parsing::Standard
- Defined in:
- lib/mindee/product/generated/generated_v1_document.rb
Overview
Generated Document V1 prediction
Instance Attribute Summary
Attributes inherited from GeneratedV1Prediction
Instance Method Summary collapse
-
#initialize(raw_prediction) ⇒ GeneratedV1Document
constructor
A new instance of GeneratedV1Document.
Methods inherited from GeneratedV1Prediction
Methods included from Mindee::Parsing::Generated
Methods inherited from Mindee::Parsing::Common::Prediction
Constructor Details
#initialize(raw_prediction) ⇒ GeneratedV1Document
Returns a new instance of GeneratedV1Document.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mindee/product/generated/generated_v1_document.rb', line 13 def initialize(raw_prediction) # Generated document. # raw_prediction: Dictionary containing the JSON document response super() raw_prediction.each do |field_name, field_contents| if field_contents.is_a?(Array) @fields[field_name] = Parsing::Generated::GeneratedListField.new(field_contents) elsif field_contents.is_a?(Hash) && Parsing::Generated.generated_object?(field_contents) @fields[field_name] = Parsing::Generated::GeneratedObjectField.new(field_contents) else field_contents_str = field_contents.dup if field_contents_str.key?('value') && field_contents_str['value'].nil? == false field_contents_str['value'] = field_contents_str['value'].to_s end @fields[field_name] = StringField.new(field_contents_str) end end end |