Class: Slamdown::Conversion::Tables::Row
- Inherits:
-
Object
- Object
- Slamdown::Conversion::Tables::Row
- Defined in:
- lib/slamdown/conversion/tables.rb
Overview
Represents one source row before span expansion.
Instance Attribute Summary collapse
-
#cells ⇒ Object
readonly
Returns the value of attribute cells.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#as_body ⇒ Object
Coerces mistaken header cells to ordinary body cells without changing their normalised contents.
- #header? ⇒ Boolean
-
#initialize(node, cells) ⇒ Row
constructor
A new instance of Row.
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
#cells ⇒ Object (readonly)
Returns the value of attribute cells.
17 18 19 |
# File 'lib/slamdown/conversion/tables.rb', line 17 def cells @cells end |
#node ⇒ Object (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_body ⇒ Object
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
25 26 27 |
# File 'lib/slamdown/conversion/tables.rb', line 25 def header? !cells.empty? && cells.all? { |cell| cell.source_name == "th" } end |