Class: Mindee::Product::Generated::GeneratedV1Prediction

Inherits:
Mindee::Parsing::Common::Prediction show all
Includes:
Mindee::Parsing::Common, Mindee::Parsing::Generated, Mindee::Parsing::Standard
Defined in:
lib/mindee/product/generated/generated_v1_prediction.rb

Overview

Generated Document V1 page.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mindee::Parsing::Generated

generated_object?

Constructor Details

#initializeGeneratedV1Prediction

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

#fieldsHash<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_sObject

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