Class: Slamdown::Conversion::Tables::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/slamdown/conversion/tables.rb

Overview

Represents one source row before span expansion.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, cells) ⇒ Row

Returns a new instance of Row.



19
20
21
22
23
# File 'lib/slamdown/conversion/tables.rb', line 19

def initialize(node, cells)
	@node = node
	@cells = cells.freeze
	freeze
end

Instance Attribute Details

#cellsObject (readonly)

Returns the value of attribute cells.



17
18
19
# File 'lib/slamdown/conversion/tables.rb', line 17

def cells
  @cells
end

#nodeObject (readonly)

Returns the value of attribute node.



17
18
19
# File 'lib/slamdown/conversion/tables.rb', line 17

def node
  @node
end

Instance Method Details

#as_bodyObject

Coerces mistaken header cells to ordinary body cells without changing their normalised contents.



30
31
32
33
34
35
# File 'lib/slamdown/conversion/tables.rb', line 30

def as_body
	body_cells = cells.map do |cell|
		cell.source_name == "th" ? cell.with(:source_name => "td") : cell
	end
	self.class.new(node.with(:children => body_cells), body_cells)
end

#header?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/slamdown/conversion/tables.rb', line 25

def header?
	!cells.empty? && cells.all? { |cell| cell.source_name == "th" }
end