class AmazonTRP::Table

Attributes

block[R]
confidence[R]
geometry[R]
id[R]
rows[R]

Public Class Methods

new(block, blockMap) click to toggle source
# 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

Public Instance Methods

to_s() click to toggle source
# 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