Class: Paru::PandocFilter::TableBody

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

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ TableBody

Create a new TableBody

Parameters:

  • contents (Array)

    The contents of this 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

#attrObject

Returns Attr.

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

#rowheadcolumnsObject

columns.

Returns:

  • Value containing an Integer indicating the number of head



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

#rowheadcolumnspecObject

Returns the value of attribute rowheadcolumnspec.



40
41
42
# File 'lib/paru/filter/table_body.rb', line 40

def rowheadcolumnspec
  @rowheadcolumnspec
end

#rowheadercolumnsObject

Returns the value of attribute rowheadercolumns.



40
41
42
# File 'lib/paru/filter/table_body.rb', line 40

def rowheadercolumns
  @rowheadercolumns
end

#rowheadercolumsRow

Returns:



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

#rowsArray<Row>

The rows in this TableBody

Returns:



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_contentsArray

The AST contents of this TableBody

Returns:

  • (Array)


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_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



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_astHash

Create an AST representation of this Node

Returns:

  • (Hash)


78
79
80
# File 'lib/paru/filter/table_body.rb', line 78

def to_ast()
  ast_contents()
end