Class: Mindee::Product::Generated::GeneratedV1PagePrediction
- Inherits:
-
GeneratedV1Prediction
- Object
- Mindee::Parsing::Common::Prediction
- GeneratedV1Prediction
- Mindee::Product::Generated::GeneratedV1PagePrediction
- Defined in:
- lib/mindee/product/generated/generated_v1_page.rb
Overview
Generated Document V1 page prediction.
Instance Attribute Summary
Attributes inherited from GeneratedV1Prediction
Instance Method Summary collapse
-
#initialize(raw_prediction, page_id = nil) ⇒ GeneratedV1PagePrediction
constructor
A new instance of GeneratedV1PagePrediction.
- #to_s ⇒ String
Methods included from Mindee::Parsing::Generated
Constructor Details
#initialize(raw_prediction, page_id = nil) ⇒ GeneratedV1PagePrediction
Returns a new instance of GeneratedV1PagePrediction.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mindee/product/generated/generated_v1_page.rb', line 25 def initialize(raw_prediction, page_id = nil) super() raw_prediction.each do |field_name, field_contents| if field_contents.is_a?(Array) @fields[field_name] = GeneratedListField.new(field_contents, page_id) elsif field_contents.is_a?(Hash) && Parsing::Generated.generated_object?(field_contents) @fields[field_name] = GeneratedObjectField.new(field_contents, page_id) else field_contents_str = field_contents.dup if field_contents_str.key?('value') && !field_contents_str['value'].nil? field_contents_str['value'] = field_contents_str['value'].to_s end @fields[field_name] = StringField.new(field_contents_str, page_id) end end end |
Instance Method Details
#to_s ⇒ String
43 44 45 46 47 |
# File 'lib/mindee/product/generated/generated_v1_page.rb', line 43 def to_s out_str = String.new out_str << "\n#{super}" out_str end |