class PseudoHiki::Utils::TableManager

Constants

ROW

Public Instance Methods

guess_header_scope(table) click to toggle source
# File lib/pseudohiki/utils.rb, line 36
def guess_header_scope(table)
  col_scope?(table) or row_scope?(table)
end

Private Instance Methods

col_scope?(table) click to toggle source
# File lib/pseudohiki/utils.rb, line 42
def col_scope?(table)
  table.each_with_index do |row, i|
    row.each do |cell|
      return if cell.rowspan > 1 or cell.colspan > 1
      # The first row sould be consist of <th> elements
      # and other rows should not include <th> elements
      return unless (i == 0) == (cell.cell_type == TH)
    end
  end
  COL
end
row_scope?(table) click to toggle source
# File lib/pseudohiki/utils.rb, line 54
def row_scope?(table)
  table.each do |row|
    row.each_with_index do |cell, j|
      return if cell.rowspan > 1 or cell.colspan > 1
      # The first column sould be consist of <th> elements
      # and other columns should not include <th> elements
      return unless (j == 0) == (cell.cell_type == TH)
    end
  end
  ROW
end