Class: OCI::AiVision::Models::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/ai_vision/models/page.rb

Overview

One page document analysis result.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Page

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/oci/ai_vision/models/page.rb', line 88

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.page_number = attributes[:'pageNumber'] if attributes[:'pageNumber']

  raise 'You cannot provide both :pageNumber and :page_number' if attributes.key?(:'pageNumber') && attributes.key?(:'page_number')

  self.page_number = attributes[:'page_number'] if attributes[:'page_number']

  self.dimensions = attributes[:'dimensions'] if attributes[:'dimensions']

  self.detected_document_types = attributes[:'detectedDocumentTypes'] if attributes[:'detectedDocumentTypes']

  raise 'You cannot provide both :detectedDocumentTypes and :detected_document_types' if attributes.key?(:'detectedDocumentTypes') && attributes.key?(:'detected_document_types')

  self.detected_document_types = attributes[:'detected_document_types'] if attributes[:'detected_document_types']

  self.detected_languages = attributes[:'detectedLanguages'] if attributes[:'detectedLanguages']

  raise 'You cannot provide both :detectedLanguages and :detected_languages' if attributes.key?(:'detectedLanguages') && attributes.key?(:'detected_languages')

  self.detected_languages = attributes[:'detected_languages'] if attributes[:'detected_languages']

  self.words = attributes[:'words'] if attributes[:'words']

  self.lines = attributes[:'lines'] if attributes[:'lines']

  self.tables = attributes[:'tables'] if attributes[:'tables']

  self.document_fields = attributes[:'documentFields'] if attributes[:'documentFields']

  raise 'You cannot provide both :documentFields and :document_fields' if attributes.key?(:'documentFields') && attributes.key?(:'document_fields')

  self.document_fields = attributes[:'document_fields'] if attributes[:'document_fields']
end

Instance Attribute Details

#detected_document_typesArray<OCI::AiVision::Models::DetectedDocumentType>

An array of detected document types.



20
21
22
# File 'lib/oci/ai_vision/models/page.rb', line 20

def detected_document_types
  @detected_document_types
end

#detected_languagesArray<OCI::AiVision::Models::DetectedLanguage>

An array of detected languages.



24
25
26
# File 'lib/oci/ai_vision/models/page.rb', line 24

def detected_languages
  @detected_languages
end

#dimensionsOCI::AiVision::Models::Dimensions



16
17
18
# File 'lib/oci/ai_vision/models/page.rb', line 16

def dimensions
  @dimensions
end

#document_fieldsArray<OCI::AiVision::Models::DocumentField>

The form fields detected on the page.



40
41
42
# File 'lib/oci/ai_vision/models/page.rb', line 40

def document_fields
  @document_fields
end

#linesArray<OCI::AiVision::Models::Line>

The lines of text detected on the page.

Returns:



32
33
34
# File 'lib/oci/ai_vision/models/page.rb', line 32

def lines
  @lines
end

#page_numberInteger

[Required] The document page number.

Returns:

  • (Integer)


13
14
15
# File 'lib/oci/ai_vision/models/page.rb', line 13

def page_number
  @page_number
end

#tablesArray<OCI::AiVision::Models::Table>

The tables detected on the page.

Returns:



36
37
38
# File 'lib/oci/ai_vision/models/page.rb', line 36

def tables
  @tables
end

#wordsArray<OCI::AiVision::Models::Word>

The words detected on the page.

Returns:



28
29
30
# File 'lib/oci/ai_vision/models/page.rb', line 28

def words
  @words
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/oci/ai_vision/models/page.rb', line 43

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'page_number': :'pageNumber',
    'dimensions': :'dimensions',
    'detected_document_types': :'detectedDocumentTypes',
    'detected_languages': :'detectedLanguages',
    'words': :'words',
    'lines': :'lines',
    'tables': :'tables',
    'document_fields': :'documentFields'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/oci/ai_vision/models/page.rb', line 59

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'page_number': :'Integer',
    'dimensions': :'OCI::AiVision::Models::Dimensions',
    'detected_document_types': :'Array<OCI::AiVision::Models::DetectedDocumentType>',
    'detected_languages': :'Array<OCI::AiVision::Models::DetectedLanguage>',
    'words': :'Array<OCI::AiVision::Models::Word>',
    'lines': :'Array<OCI::AiVision::Models::Line>',
    'tables': :'Array<OCI::AiVision::Models::Table>',
    'document_fields': :'Array<OCI::AiVision::Models::DocumentField>'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/oci/ai_vision/models/page.rb', line 134

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    page_number == other.page_number &&
    dimensions == other.dimensions &&
    detected_document_types == other.detected_document_types &&
    detected_languages == other.detected_languages &&
    words == other.words &&
    lines == other.lines &&
    tables == other.tables &&
    document_fields == other.document_fields
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/oci/ai_vision/models/page.rb', line 171

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


151
152
153
# File 'lib/oci/ai_vision/models/page.rb', line 151

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



160
161
162
# File 'lib/oci/ai_vision/models/page.rb', line 160

def hash
  [page_number, dimensions, detected_document_types, detected_languages, words, lines, tables, document_fields].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



204
205
206
207
208
209
210
211
212
213
# File 'lib/oci/ai_vision/models/page.rb', line 204

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



198
199
200
# File 'lib/oci/ai_vision/models/page.rb', line 198

def to_s
  to_hash.to_s
end