Module: Taka::DOM::HTML::TableElement
- Defined in:
- lib/taka/dom/html/table_element.rb
Instance Method Summary collapse
- #caption ⇒ Object
- #createCaption ⇒ Object
- #createTFoot ⇒ Object
- #createTHead ⇒ Object
- #deleteCaption ⇒ Object
- #deleteRow(index) ⇒ Object
- #deleteTFoot ⇒ Object
- #deleteTHead ⇒ Object
- #insertRow(index) ⇒ Object
- #rows ⇒ Object
- #tBodies ⇒ Object
- #tFoot ⇒ Object
- #tHead ⇒ Object
Instance Method Details
#caption ⇒ Object
32 33 34 |
# File 'lib/taka/dom/html/table_element.rb', line 32 def caption at('./caption') end |
#createCaption ⇒ Object
73 74 75 76 77 78 |
# File 'lib/taka/dom/html/table_element.rb', line 73 def createCaption return self.caption if caption my_caption = Nokogiri::XML::Node.new('caption', document) add_child my_caption my_caption end |
#createTFoot ⇒ Object
61 62 63 64 65 66 |
# File 'lib/taka/dom/html/table_element.rb', line 61 def createTFoot return self.tFoot if tFoot foot = Nokogiri::XML::Node.new('tfoot', document) add_child foot foot end |
#createTHead ⇒ Object
48 49 50 51 52 53 |
# File 'lib/taka/dom/html/table_element.rb', line 48 def createTHead head = tHead return head if head head = Nokogiri::XML::Node.new('thead', document) add_child head end |
#deleteCaption ⇒ Object
80 81 82 83 |
# File 'lib/taka/dom/html/table_element.rb', line 80 def deleteCaption caption.unlink if caption nil end |
#deleteRow(index) ⇒ Object
28 29 30 |
# File 'lib/taka/dom/html/table_element.rb', line 28 def deleteRow index (row = rows[index]) && row.unlink end |
#deleteTFoot ⇒ Object
68 69 70 71 |
# File 'lib/taka/dom/html/table_element.rb', line 68 def deleteTFoot tFoot.unlink if tFoot nil end |
#deleteTHead ⇒ Object
55 56 57 58 59 |
# File 'lib/taka/dom/html/table_element.rb', line 55 def deleteTHead head = tHead head.unlink if head nil end |
#insertRow(index) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/taka/dom/html/table_element.rb', line 11 def insertRow index tr = Nokogiri::XML::Node.new('tr', self.document) sibling = rows[index] || rows.last if rows.length == 0 add_child Nokogiri::XML::Node.new('tbody', document) end if !sibling self.add_child tr else sibling.add_previous_sibling tr end tr end |
#rows ⇒ Object
5 6 7 8 9 |
# File 'lib/taka/dom/html/table_element.rb', line 5 def rows DOM::NodeList.new { xpath('./thead/tr', './tbody/tr', './tr', './tfoot/tr') } end |
#tBodies ⇒ Object
44 45 46 |
# File 'lib/taka/dom/html/table_element.rb', line 44 def tBodies xpath('./tbody') end |
#tFoot ⇒ Object
40 41 42 |
# File 'lib/taka/dom/html/table_element.rb', line 40 def tFoot at('./tfoot') end |
#tHead ⇒ Object
36 37 38 |
# File 'lib/taka/dom/html/table_element.rb', line 36 def tHead at('./thead') end |