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
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/paru/filter/table_body.rb', line 45 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.
39 40 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 39 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 {|r| r.to_ast}, @children.map {|child| child.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 do |row| row.to_array end end end |
#rowheadcolumns ⇒ Object
columns.
39 40 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 39 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 {|r| r.to_ast}, @children.map {|child| child.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 do |row| row.to_array end end end |
#rowheadcolumnspec ⇒ Object
Returns the value of attribute rowheadcolumnspec.
40 41 42 |
# File 'lib/paru/filter/table_body.rb', line 40 def rowheadcolumnspec @rowheadcolumnspec end |
#rowheadercolumns ⇒ Object
Returns the value of attribute rowheadercolumns.
40 41 42 |
# File 'lib/paru/filter/table_body.rb', line 40 def rowheadercolumns @rowheadercolumns end |
#rowheadercolums ⇒ Row
39 40 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 39 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 {|r| r.to_ast}, @children.map {|child| child.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 do |row| row.to_array end end end |
#rows ⇒ Array<Row>
The rows in this TableBody
39 40 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 39 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 {|r| r.to_ast}, @children.map {|child| child.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 do |row| row.to_array end end end |
Instance Method Details
#ast_contents ⇒ Array
The AST contents of this TableBody
66 67 68 69 70 71 72 73 |
# File 'lib/paru/filter/table_body.rb', line 66 def ast_contents [ @attr.to_ast, @rowheadcolumns.to_ast, @rowheadercolumns.map {|r| r.to_ast}, @children.map {|child| child.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.
87 88 89 90 91 |
# File 'lib/paru/filter/table_body.rb', line 87 def to_array() @children.map do |row| row.to_array end end |
#to_ast ⇒ Hash
Create an AST representation of this Node
78 79 80 |
# File 'lib/paru/filter/table_body.rb', line 78 def to_ast() ast_contents() end |