Module: Taka::DOM::HTML::TableRowElement

Defined in:
lib/taka/dom/html/table_row_element.rb

Instance Method Summary collapse

Instance Method Details

#cellsObject



17
18
19
# File 'lib/taka/dom/html/table_row_element.rb', line 17

def cells
  xpath('.//td', './/th')
end

#chObject



41
42
43
# File 'lib/taka/dom/html/table_row_element.rb', line 41

def ch
  self['char']
end

#chOffObject



45
46
47
# File 'lib/taka/dom/html/table_row_element.rb', line 45

def chOff
  self['charoff']
end

#deleteCell(index) ⇒ Object



37
38
39
# File 'lib/taka/dom/html/table_row_element.rb', line 37

def deleteCell index
  (cell = cells[index]) && cell.unlink
end

#insertCell(index) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/taka/dom/html/table_row_element.rb', line 27

def insertCell index
  td = Nokogiri::XML::Node.new('td', self.document)
  cell = cells[index]
  if cell
    cell.add_previous_sibling td
  else
    add_child td
  end
end

#rowIndexObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/taka/dom/html/table_row_element.rb', line 5

def rowIndex
  parent_table = self.parent
  while parent_table.name != 'table'
    parent_table = parent_table.parent
  end

  parent_table.rows.each_with_index do |row, i|
    return i if row == self
  end
  raise
end

#sectionRowIndexObject



21
22
23
24
25
# File 'lib/taka/dom/html/table_row_element.rb', line 21

def sectionRowIndex
  parent.xpath('./tr').each_with_index do |tr, i|
    return i if tr == self
  end
end