Class: AmazonTRP::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/amazon-textract-parser-ruby.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, blockMap) ⇒ Cell

Returns a new instance of Cell.



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/amazon-textract-parser-ruby.rb', line 323

def initialize(block, blockMap)
  @block = block
  @confidence = block[:confidence]
  @rowIndex = block[:row_index]
  @columnIndex = block[:column_index]
  @rowSpan = block[:row_span]
  @columnSpan = block[:column_span]
  @geometry = Geometry.new(block[:geometry])
  @id = block[:id]
  @content = []
  @text = ""
  if block[:relationships]
    block[:relationships].each do |rs|
      if rs[:type] == 'CHILD'
        for cid in rs[:ids]
          blockType = blockMap[cid][:block_type]
          if blockType == "WORD"
            w = Word.new(blockMap[cid], blockMap)
            @content.append(w)
            @text = @text + w.text + ' '
          elsif blockType == "SELECTION_ELEMENT"
            se = SelectionElement.new(blockMap[cid], blockMap)
            @content.append(se)
            @text = @text + se.selectionStatus + ', '
          end
        end
      end
    end
  end
  @text = @text.strip
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



321
322
323
# File 'lib/amazon-textract-parser-ruby.rb', line 321

def block
  @block
end

#columnIndexObject (readonly)

Returns the value of attribute columnIndex.



314
315
316
# File 'lib/amazon-textract-parser-ruby.rb', line 314

def columnIndex
  @columnIndex
end

#columnSpanObject (readonly)

Returns the value of attribute columnSpan.



316
317
318
# File 'lib/amazon-textract-parser-ruby.rb', line 316

def columnSpan
  @columnSpan
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



312
313
314
# File 'lib/amazon-textract-parser-ruby.rb', line 312

def confidence
  @confidence
end

#contentObject (readonly)

Returns the value of attribute content.



319
320
321
# File 'lib/amazon-textract-parser-ruby.rb', line 319

def content
  @content
end

#geometryObject (readonly)

Returns the value of attribute geometry.



317
318
319
# File 'lib/amazon-textract-parser-ruby.rb', line 317

def geometry
  @geometry
end

#idObject (readonly)

Returns the value of attribute id.



318
319
320
# File 'lib/amazon-textract-parser-ruby.rb', line 318

def id
  @id
end

#rowIndexObject (readonly)

Returns the value of attribute rowIndex.



313
314
315
# File 'lib/amazon-textract-parser-ruby.rb', line 313

def rowIndex
  @rowIndex
end

#rowSpanObject (readonly)

Returns the value of attribute rowSpan.



315
316
317
# File 'lib/amazon-textract-parser-ruby.rb', line 315

def rowSpan
  @rowSpan
end

#textObject (readonly)

Returns the value of attribute text.



320
321
322
# File 'lib/amazon-textract-parser-ruby.rb', line 320

def text
  @text
end

Instance Method Details

#to_sObject



355
356
357
# File 'lib/amazon-textract-parser-ruby.rb', line 355

def to_s
  @text
end