Class: Mindee::Product::Universal::UniversalPrediction
- Inherits:
-
Mindee::Parsing::Common::Prediction
- Object
- Mindee::Parsing::Common::Prediction
- Mindee::Product::Universal::UniversalPrediction
- Defined in:
- lib/mindee/product/universal/universal_prediction.rb
Overview
Universal Document V1 page.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fields ⇒ Hash<Symbol, Mindee::Parsing::Universal::UniversalListField>
readonly
All value fields in the document.
Instance Method Summary collapse
-
#initialize(_ = nil) ⇒ UniversalPrediction
constructor
A new instance of UniversalPrediction.
-
#to_s ⇒ Object
String representation.
Methods included from Mindee::Parsing::Universal
Constructor Details
#initialize(_ = nil) ⇒ UniversalPrediction
Returns a new instance of UniversalPrediction.
17 18 19 20 |
# File 'lib/mindee/product/universal/universal_prediction.rb', line 17 def initialize(_ = nil) super @fields = {} # : Hash[Symbol | String, untyped] end |
Instance Attribute Details
#fields ⇒ Hash<Symbol, Mindee::Parsing::Universal::UniversalListField> (readonly)
All value fields in the document
15 16 17 |
# File 'lib/mindee/product/universal/universal_prediction.rb', line 15 def fields @fields end |
Instance Method Details
#to_s ⇒ Object
String representation.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mindee/product/universal/universal_prediction.rb', line 23 def to_s out_str = '' pattern = %r{^(\n* *)( {2}):} @fields.each do |field_name, field_value| str_value = if field_value.is_a?( Mindee::Parsing::Universal::UniversalListField ) && field_value.values.length.positive? generate_field_string(field_name, field_value, pattern) else field_value.to_s end out_str += "\n:#{field_name}:" out_str += " #{str_value}".sub(%r{^\s+\n}, "\n") if str_value.length.positive? end out_str.sub("\n", '') end |