Class: Mindee::Product::Generated::GeneratedV1Prediction
- Inherits:
-
Mindee::Parsing::Common::Prediction
- Object
- Mindee::Parsing::Common::Prediction
- Mindee::Product::Generated::GeneratedV1Prediction
- Defined in:
- lib/mindee/product/generated/generated_v1_prediction.rb
Overview
Generated Document V1 page.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fields ⇒ Hash<Symbol, Mindee::Parsing::Generated::GeneratedListField>
readonly
All value fields in the document.
Instance Method Summary collapse
-
#initialize ⇒ GeneratedV1Prediction
constructor
A new instance of GeneratedV1Prediction.
-
#to_s ⇒ Object
String representation.
Methods included from Mindee::Parsing::Generated
Constructor Details
#initialize ⇒ GeneratedV1Prediction
Returns a new instance of GeneratedV1Prediction.
17 18 19 20 |
# File 'lib/mindee/product/generated/generated_v1_prediction.rb', line 17 def initialize super() @fields = {} end |
Instance Attribute Details
#fields ⇒ Hash<Symbol, Mindee::Parsing::Generated::GeneratedListField> (readonly)
All value fields in the document
15 16 17 |
# File 'lib/mindee/product/generated/generated_v1_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 |
# File 'lib/mindee/product/generated/generated_v1_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?(GeneratedListField) && 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 |