Class: Paru::PandocFilter::TableEnd

Inherits:
Block
  • Object
show all
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.

Direct Known Subclasses

TableFoot, TableHead

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ TableEnd

Create a new TableEnd based on the contents

Parameters:

  • contents (Array)


39
40
41
42
43
44
45
# File 'lib/paru/filter/table_end.rb', line 39

def initialize(contents)
    @attr = Attr.new contents[0]
    super []
    contents[1].each do |row|
        @children.push Row.new row
    end
end

Instance Attribute Details

#attrObject

Returns Attr.

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

#rowsRow

Returns:



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_contentsArray

The AST contents of this Table node

Returns:

  • (Array)


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_arrayString[][]

Convert this table end to a 2D table of markdown strings for each cell

represented by their markdown strings.

Returns:

  • (String[][])

    This Table as a 2D array of cells



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_astHash

Create an AST representation of this Node

Returns:

  • (Hash)


64
65
66
# File 'lib/paru/filter/table_end.rb', line 64

def to_ast()
  ast_contents()
end