Class: Paru::PandocFilter::TableEnd
- Defined in:
- lib/paru/filter/table_end.rb
Overview
A TableEnd node is the base class for the TableHead and TableFoot nodes. It has attributes and one or more rows.
Instance Attribute Summary collapse
-
#attr ⇒ Object
Attr.
- #rows ⇒ Row
Instance Method Summary collapse
-
#ast_contents ⇒ Array
The AST contents of this Table node.
-
#initialize(contents) ⇒ TableEnd
constructor
Create a new TableEnd based on the contents.
-
#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
Instance Attribute Details
#attr ⇒ Object
Returns Attr.
33 34 35 36 37 38 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 |
# File 'lib/paru/filter/table_end.rb', line 33 class TableEnd < Block attr_accessor :attr # Create a new TableEnd based on the contents # # @param contents [Array] def initialize(contents) @attr = Attr.new contents[0] super [] contents[1].each do |row| @children.push Row.new row end end def rows() @children end # The AST contents of this Table node # # @return [Array] def ast_contents() [ @attr.to_ast, @children.map {|row| row.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 ⇒ Row
33 34 35 36 37 38 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 |
# File 'lib/paru/filter/table_end.rb', line 33 class TableEnd < Block attr_accessor :attr # Create a new TableEnd based on the contents # # @param contents [Array] def initialize(contents) @attr = Attr.new contents[0] super [] contents[1].each do |row| @children.push Row.new row end end def rows() @children end # The AST contents of this Table node # # @return [Array] def ast_contents() [ @attr.to_ast, @children.map {|row| row.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 Table node
54 55 56 57 58 59 |
# File 'lib/paru/filter/table_end.rb', line 54 def ast_contents() [ @attr.to_ast, @children.map {|row| row.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.
73 74 75 76 77 |
# File 'lib/paru/filter/table_end.rb', line 73 def to_array() @children.map do |row| row.to_array end end |
#to_ast ⇒ Hash
Create an AST representation of this Node
64 65 66 |
# File 'lib/paru/filter/table_end.rb', line 64 def to_ast() ast_contents() end |