Class: Paru::PandocFilter::TableBody
- Defined in:
- lib/paru/filter/table_body.rb
Overview
A TableBody node represents a row in a table’s head or body
Instance Attribute Summary collapse
-
#attr ⇒ Object
Attr.
-
#rowheadcolumns ⇒ Object
columns.
-
#rowheadcolumnspec ⇒ Object
Returns the value of attribute rowheadcolumnspec.
-
#rowheadercolumns ⇒ Object
Returns the value of attribute rowheadercolumns.
- #rowheadercolums ⇒ Row
-
#rows ⇒ Array<Row>
The rows in this TableBody.
Instance Method Summary collapse
-
#ast_contents ⇒ Array
The AST contents of this TableBody.
-
#initialize(contents) ⇒ TableBody
constructor
Create a new TableBody.
-
#to_array ⇒ String[][]
Convert this table end to a 2D table of markdown strings for each cell.
-
#to_ast ⇒ Hash
Create an AST representation of this Node.
Constructor Details
#initialize(contents) ⇒ TableBody
Create a new TableBody
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/paru/filter/table_body.rb', line 47 def initialize(contents) @attr = Attr.new contents[0] @rowheadcolumns = IntValue.new contents[1] @rowheadercolumns = contents[2].map { |r| Row.new r } super([]) contents[3].each do |row| @children.push Row.new row end end |
Instance Attribute Details
#attr ⇒ Object
Returns Attr.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/paru/filter/table_body.rb', line 41 class TableBody < Block attr_accessor :attr, :rowheadcolumnspec, :rowheadercolumns # Create a new TableBody # # @param contents [Array] The contents of this TableBody def initialize(contents) @attr = Attr.new contents[0] @rowheadcolumns = IntValue.new contents[1] @rowheadercolumns = contents[2].map { |r| Row.new r } super([]) contents[3].each do |row| @children.push Row.new row end end # The rows in this TableBody # # @return [Array<Row>] def rows @children end # The AST contents of this TableBody # # @return [Array] def ast_contents [ @attr.to_ast, @rowheadcolumns.to_ast, @rowheadercolumns.map(&:to_ast), @children.map(&:to_ast) ] end # Create an AST representation of this Node # # @return [Hash] def to_ast ast_contents end # Convert this table end to a 2D table of markdown strings for each # cell # # @return [String[][]] This Table as a 2D array of cells # represented by their markdown strings. def to_array @children.map(&:to_array) end end |
#rowheadcolumns ⇒ Object
columns.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/paru/filter/table_body.rb', line 41 class TableBody < Block attr_accessor :attr, :rowheadcolumnspec, :rowheadercolumns # Create a new TableBody # # @param contents [Array] The contents of this TableBody def initialize(contents) @attr = Attr.new contents[0] @rowheadcolumns = IntValue.new contents[1] @rowheadercolumns = contents[2].map { |r| Row.new r } super([]) contents[3].each do |row| @children.push Row.new row end end # The rows in this TableBody # # @return [Array<Row>] def rows @children end # The AST contents of this TableBody # # @return [Array] def ast_contents [ @attr.to_ast, @rowheadcolumns.to_ast, @rowheadercolumns.map(&:to_ast), @children.map(&:to_ast) ] end # Create an AST representation of this Node # # @return [Hash] def to_ast ast_contents end # Convert this table end to a 2D table of markdown strings for each # cell # # @return [String[][]] This Table as a 2D array of cells # represented by their markdown strings. def to_array @children.map(&:to_array) end end |
#rowheadcolumnspec ⇒ Object
Returns the value of attribute rowheadcolumnspec.
42 43 44 |
# File 'lib/paru/filter/table_body.rb', line 42 def rowheadcolumnspec @rowheadcolumnspec end |
#rowheadercolumns ⇒ Object
Returns the value of attribute rowheadercolumns.
42 43 44 |
# File 'lib/paru/filter/table_body.rb', line 42 def rowheadercolumns @rowheadercolumns end |
#rowheadercolums ⇒ Row
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/paru/filter/table_body.rb', line 41 class TableBody < Block attr_accessor :attr, :rowheadcolumnspec, :rowheadercolumns # Create a new TableBody # # @param contents [Array] The contents of this TableBody def initialize(contents) @attr = Attr.new contents[0] @rowheadcolumns = IntValue.new contents[1] @rowheadercolumns = contents[2].map { |r| Row.new r } super([]) contents[3].each do |row| @children.push Row.new row end end # The rows in this TableBody # # @return [Array<Row>] def rows @children end # The AST contents of this TableBody # # @return [Array] def ast_contents [ @attr.to_ast, @rowheadcolumns.to_ast, @rowheadercolumns.map(&:to_ast), @children.map(&:to_ast) ] end # Create an AST representation of this Node # # @return [Hash] def to_ast ast_contents end # Convert this table end to a 2D table of markdown strings for each # cell # # @return [String[][]] This Table as a 2D array of cells # represented by their markdown strings. def to_array @children.map(&:to_array) end end |
#rows ⇒ Array<Row>
The rows in this TableBody
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/paru/filter/table_body.rb', line 41 class TableBody < Block attr_accessor :attr, :rowheadcolumnspec, :rowheadercolumns # Create a new TableBody # # @param contents [Array] The contents of this TableBody def initialize(contents) @attr = Attr.new contents[0] @rowheadcolumns = IntValue.new contents[1] @rowheadercolumns = contents[2].map { |r| Row.new r } super([]) contents[3].each do |row| @children.push Row.new row end end # The rows in this TableBody # # @return [Array<Row>] def rows @children end # The AST contents of this TableBody # # @return [Array] def ast_contents [ @attr.to_ast, @rowheadcolumns.to_ast, @rowheadercolumns.map(&:to_ast), @children.map(&:to_ast) ] end # Create an AST representation of this Node # # @return [Hash] def to_ast ast_contents end # Convert this table end to a 2D table of markdown strings for each # cell # # @return [String[][]] This Table as a 2D array of cells # represented by their markdown strings. def to_array @children.map(&:to_array) end end |
Instance Method Details
#ast_contents ⇒ Array
The AST contents of this TableBody
68 69 70 71 72 73 74 75 |
# File 'lib/paru/filter/table_body.rb', line 68 def ast_contents [ @attr.to_ast, @rowheadcolumns.to_ast, @rowheadercolumns.map(&:to_ast), @children.map(&:to_ast) ] end |
#to_array ⇒ String[][]
Convert this table end to a 2D table of markdown strings for each cell
represented by their markdown strings.
89 90 91 |
# File 'lib/paru/filter/table_body.rb', line 89 def to_array @children.map(&:to_array) end |
#to_ast ⇒ Hash
Create an AST representation of this Node
80 81 82 |
# File 'lib/paru/filter/table_body.rb', line 80 def to_ast ast_contents end |