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



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

#attrObject

Returns Attr.

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

#rowheadcolumnsObject

columns.

Returns:

  • Value containing an Integer indicating the number of head



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

#rowheadcolumnspecObject

Returns the value of attribute rowheadcolumnspec.



42
43
44
# File 'lib/paru/filter/table_body.rb', line 42

def rowheadcolumnspec
  @rowheadcolumnspec
end

#rowheadercolumnsObject

Returns the value of attribute rowheadercolumns.



42
43
44
# File 'lib/paru/filter/table_body.rb', line 42

def rowheadercolumns
  @rowheadercolumns
end

#rowheadercolumsRow

Returns:



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

#rowsArray<Row>

The rows in this TableBody

Returns:



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_contentsArray

The AST contents of this TableBody

Returns:

  • (Array)


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



89
90
91
# File 'lib/paru/filter/table_body.rb', line 89

def to_array
  @children.map(&:to_array)
end

#to_astHash

Create an AST representation of this Node

Returns:

  • (Hash)


80
81
82
# File 'lib/paru/filter/table_body.rb', line 80

def to_ast
  ast_contents
end