Class: AmazonTRP::Table

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) ⇒ Table

Returns a new instance of Table.



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/amazon-textract-parser-ruby.rb', line 385

def initialize(block, blockMap)
  @block = block
  
  @confidence = block[:confidence]
  @geometry = Geometry.new(block[:geometry])
  
  @id = block[:id]
  @rows = []
  
  ri = 1
  row = Row.new()
  cell = nil
  if block[:relationships]
    block[:relationships].each do |rs|
      if rs[:type] == 'CHILD'
        for cid in rs[:ids]
          cell = Cell.new(blockMap[cid], blockMap)
          if cell.rowIndex > ri
            @rows.append(row)
            row = Row.new()
            ri = cell.rowIndex
          end
          row.cells.append(cell)
        end
        @rows.append(row) if row && row.cells
      end
    end
  end
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



383
384
385
# File 'lib/amazon-textract-parser-ruby.rb', line 383

def block
  @block
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



379
380
381
# File 'lib/amazon-textract-parser-ruby.rb', line 379

def confidence
  @confidence
end

#geometryObject (readonly)

Returns the value of attribute geometry.



380
381
382
# File 'lib/amazon-textract-parser-ruby.rb', line 380

def geometry
  @geometry
end

#idObject (readonly)

Returns the value of attribute id.



381
382
383
# File 'lib/amazon-textract-parser-ruby.rb', line 381

def id
  @id
end

#rowsObject (readonly)

Returns the value of attribute rows.



382
383
384
# File 'lib/amazon-textract-parser-ruby.rb', line 382

def rows
  @rows
end

Instance Method Details

#to_sObject



415
416
417
418
419
420
421
# File 'lib/amazon-textract-parser-ruby.rb', line 415

def to_s
  s = "Table:\n"
  @rows.each do |row|
    s = s + row.to_s + "\n"
  end
  return s
end