Class: Mindee::V1::Product::Universal::UniversalPrediction
- Inherits:
-
Mindee::V1::Parsing::Common::Prediction
- Object
- Mindee::V1::Parsing::Common::Prediction
- Mindee::V1::Product::Universal::UniversalPrediction
- Includes:
- Mindee::V1::Parsing::Common, Mindee::V1::Parsing::Standard, Mindee::V1::Parsing::Universal
- Defined in:
- lib/mindee/v1/product/universal/universal_prediction.rb
Overview
Universal Document V1 page.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fields ⇒ Hash<Symbol, Mindee::V1::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::V1::Parsing::Universal
Constructor Details
#initialize(_ = nil) ⇒ UniversalPrediction
Returns a new instance of UniversalPrediction.
19 20 21 22 |
# File 'lib/mindee/v1/product/universal/universal_prediction.rb', line 19 def initialize(_ = nil) super @fields = {} # : Hash[String | Symbol, untyped] end |
Instance Attribute Details
#fields ⇒ Hash<Symbol, Mindee::V1::Parsing::Universal::UniversalListField> (readonly)
All value fields in the document
17 18 19 |
# File 'lib/mindee/v1/product/universal/universal_prediction.rb', line 17 def fields @fields end |
Instance Method Details
#to_s ⇒ Object
String representation.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mindee/v1/product/universal/universal_prediction.rb', line 25 def to_s out_str = '' pattern = %r{^(\n* *)( {2}):} @fields.each do |field_name, field_value| str_value = if field_value.is_a?( Mindee::V1::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 |