Class: Paru::PandocFilter::Cell

Inherits:
Block show all
Defined in:
lib/paru/filter/cell.rb

Overview

A Cell node represents a cell in a table's head, body, or foot.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Cell

Create a new Cell based on the row_data

Parameters:

  • contents (Array)


45
46
47
48
49
50
51
52
# File 'lib/paru/filter/cell.rb', line 45

def initialize(contents)
    @attr = Attr.new contents[0]
    @alignment = Value.new contents[1]
    @rowspan = IntValue.new contents[2]
    @colspan = IntValue.new contents[3]

    super contents[4]
end

Instance Attribute Details

#alignmentObject

AlignCenter, or AlignDefault.

Returns:

  • Value containing a String, one of AlignRight, AlignLeft,



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
# File 'lib/paru/filter/cell.rb', line 39

class Cell < Block
    attr_accessor :attr, :alignment, :rowspan, :colspan

    # Create a new Cell based on the row_data
    #
    # @param contents [Array]
    def initialize(contents)
        @attr = Attr.new contents[0]
        @alignment = Value.new contents[1]
        @rowspan = IntValue.new contents[2]
        @colspan = IntValue.new contents[3]

        super contents[4]
    end

    # The AST contents of this Cell
    #
    # @return [Array]
    def ast_contents
        [
          @attr.to_ast,
          @alignment.to_ast,
          @rowspan.to_ast,
          @colspan.to_ast,
          @children.map {|child| child.to_ast}
        ]
    end

    # Create an AST representation of this Node
    #
    # @return [Hash]
    def to_ast()
      ast_contents()
    end
end

#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
# File 'lib/paru/filter/cell.rb', line 39

class Cell < Block
    attr_accessor :attr, :alignment, :rowspan, :colspan

    # Create a new Cell based on the row_data
    #
    # @param contents [Array]
    def initialize(contents)
        @attr = Attr.new contents[0]
        @alignment = Value.new contents[1]
        @rowspan = IntValue.new contents[2]
        @colspan = IntValue.new contents[3]

        super contents[4]
    end

    # The AST contents of this Cell
    #
    # @return [Array]
    def ast_contents
        [
          @attr.to_ast,
          @alignment.to_ast,
          @rowspan.to_ast,
          @colspan.to_ast,
          @children.map {|child| child.to_ast}
        ]
    end

    # Create an AST representation of this Node
    #
    # @return [Hash]
    def to_ast()
      ast_contents()
    end
end

#colspanObject

Returns Value containing an Integer.

Returns:

  • Value containing an Integer



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
# File 'lib/paru/filter/cell.rb', line 39

class Cell < Block
    attr_accessor :attr, :alignment, :rowspan, :colspan

    # Create a new Cell based on the row_data
    #
    # @param contents [Array]
    def initialize(contents)
        @attr = Attr.new contents[0]
        @alignment = Value.new contents[1]
        @rowspan = IntValue.new contents[2]
        @colspan = IntValue.new contents[3]

        super contents[4]
    end

    # The AST contents of this Cell
    #
    # @return [Array]
    def ast_contents
        [
          @attr.to_ast,
          @alignment.to_ast,
          @rowspan.to_ast,
          @colspan.to_ast,
          @children.map {|child| child.to_ast}
        ]
    end

    # Create an AST representation of this Node
    #
    # @return [Hash]
    def to_ast()
      ast_contents()
    end
end

#rowspanObject

Returns Value containing an Integer.

Returns:

  • Value containing an Integer



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
# File 'lib/paru/filter/cell.rb', line 39

class Cell < Block
    attr_accessor :attr, :alignment, :rowspan, :colspan

    # Create a new Cell based on the row_data
    #
    # @param contents [Array]
    def initialize(contents)
        @attr = Attr.new contents[0]
        @alignment = Value.new contents[1]
        @rowspan = IntValue.new contents[2]
        @colspan = IntValue.new contents[3]

        super contents[4]
    end

    # The AST contents of this Cell
    #
    # @return [Array]
    def ast_contents
        [
          @attr.to_ast,
          @alignment.to_ast,
          @rowspan.to_ast,
          @colspan.to_ast,
          @children.map {|child| child.to_ast}
        ]
    end

    # Create an AST representation of this Node
    #
    # @return [Hash]
    def to_ast()
      ast_contents()
    end
end

Instance Method Details

#ast_contentsArray

The AST contents of this Cell

Returns:

  • (Array)


57
58
59
60
61
62
63
64
65
# File 'lib/paru/filter/cell.rb', line 57

def ast_contents
    [
      @attr.to_ast,
      @alignment.to_ast,
      @rowspan.to_ast,
      @colspan.to_ast,
      @children.map {|child| child.to_ast}
    ]
end

#to_astHash

Create an AST representation of this Node

Returns:

  • (Hash)


70
71
72
# File 'lib/paru/filter/cell.rb', line 70

def to_ast()
  ast_contents()
end