Class: Swordfish::Node::TableCell

Inherits:
Base
  • Object
show all
Defined in:
lib/swordfish/nodes/table_cell.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#children, #content, #style

Instance Method Summary collapse

Methods inherited from Base

#append, #clear_children, #find_nodes_by_type, #inform!, #initialize, #replace, #replace_with, #stylize, #wrap_children

Constructor Details

This class inherits a constructor from Swordfish::Node::Base

Instance Attribute Details

#colspanObject (readonly)

Returns the value of attribute colspan.



10
11
12
# File 'lib/swordfish/nodes/table_cell.rb', line 10

def colspan
  @colspan
end

#merge_leftObject

Returns the value of attribute merge_left.



7
8
9
# File 'lib/swordfish/nodes/table_cell.rb', line 7

def merge_left
  @merge_left
end

#merge_upObject

Returns the value of attribute merge_up.



8
9
10
# File 'lib/swordfish/nodes/table_cell.rb', line 8

def merge_up
  @merge_up
end

#rowspanObject (readonly)

Returns the value of attribute rowspan.



9
10
11
# File 'lib/swordfish/nodes/table_cell.rb', line 9

def rowspan
  @rowspan
end

Instance Method Details

#merge_left?Boolean

True if this cell is merged with the one to the left

Returns:

  • (Boolean)


13
14
15
# File 'lib/swordfish/nodes/table_cell.rb', line 13

def merge_left?
  !!@merge_left
end

#merge_up?Boolean

True if this cell is merged with the one above

Returns:

  • (Boolean)


18
19
20
# File 'lib/swordfish/nodes/table_cell.rb', line 18

def merge_up?
  !!@merge_up
end

#to_htmlObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/swordfish/nodes/table_cell.rb', line 22

def to_html
  return nil if @colspan == 0 && @rowspan == 0

  if @rowspan && @rowspan > 1
    rowspan = " rowspan=#{@rowspan}"
  end
  if @colspan && @colspan > 1
    colspan = " colspan=#{@colspan}"
  end

  "<td#{rowspan}#{colspan}>#{@children.map(&:to_html).join}</td>"
end