Class: Mindee::Product::Universal::UniversalPagePrediction
- Inherits:
-
UniversalPrediction
- Object
- Mindee::Parsing::Common::Prediction
- UniversalPrediction
- Mindee::Product::Universal::UniversalPagePrediction
- Defined in:
- lib/mindee/product/universal/universal_page.rb
Overview
Universal Document V1 page prediction.
Instance Attribute Summary
Attributes inherited from UniversalPrediction
Instance Method Summary collapse
-
#initialize(raw_prediction, page_id = nil) ⇒ UniversalPagePrediction
constructor
A new instance of UniversalPagePrediction.
- #to_s ⇒ String
Methods included from Mindee::Parsing::Universal
Constructor Details
#initialize(raw_prediction, page_id = nil) ⇒ UniversalPagePrediction
Returns a new instance of UniversalPagePrediction.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mindee/product/universal/universal_page.rb', line 25 def initialize(raw_prediction, page_id = nil) super(raw_prediction) raw_prediction.each do |field_name, field_contents| if field_contents.is_a?(Array) @fields[field_name] = Mindee::Parsing::Universal::UniversalListField.new(field_contents, page_id) elsif field_contents.is_a?(Hash) && Parsing::Universal.universal_object?(field_contents) @fields[field_name] = Mindee::Parsing::Universal::UniversalObjectField.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] = Mindee::Parsing::Standard::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/universal/universal_page.rb', line 43 def to_s out_str = String.new out_str << "\n#{super}" out_str end |