Class: Mindee::V1::Parsing::Standard::CompanyRegistrationField

Inherits:
BaseField show all
Defined in:
lib/mindee/v1/parsing/standard/company_registration_field.rb

Overview

Company registration number or code, and its type.

Instance Attribute Summary collapse

Attributes inherited from BaseField

#reconstructed, #value

Attributes inherited from AbstractField

#bounding_box, #confidence, #page_id, #polygon

Instance Method Summary collapse

Methods inherited from AbstractField

array_confidence, array_sum, float_to_string

Constructor Details

#initialize(prediction, page_id, reconstructed: false) ⇒ CompanyRegistrationField

Returns a new instance of CompanyRegistrationField.

Parameters:

  • prediction (Hash)
  • page_id (Integer, nil)
  • reconstructed (bool) (defaults to: false)


15
16
17
18
# File 'lib/mindee/v1/parsing/standard/company_registration_field.rb', line 15

def initialize(prediction, page_id, reconstructed: false)
  super
  @type = prediction['type']
end

Instance Attribute Details

#typeString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/mindee/v1/parsing/standard/company_registration_field.rb', line 10

def type
  @type
end

Instance Method Details

#printable_valuesHash

Hashed representation of the values.

Returns:

  • (Hash)

    Hash of the values.



35
36
37
38
39
40
# File 'lib/mindee/v1/parsing/standard/company_registration_field.rb', line 35

def printable_values
  printable = {} # @type var printable: Hash[Symbol, String]
  printable[:type] = type
  printable[:value] = value.to_s
  printable
end

#to_sString

Returns:

  • (String)


28
29
30
31
# File 'lib/mindee/v1/parsing/standard/company_registration_field.rb', line 28

def to_s
  printable = printable_values
  format('Type: %<type>s, Value: %<value>s', type: printable[:type], value: printable[:value])
end

#to_table_lineString

Table line representation of the values.

Returns:

  • (String)

    The formatted table line, as a string.



22
23
24
25
# File 'lib/mindee/v1/parsing/standard/company_registration_field.rb', line 22

def to_table_line
  printable = printable_values
  format('| %<type>-15s | %<value>-20s ', type: printable[:type], value: printable[:value])
end