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)


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

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,



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

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(&:to_ast)
    ]
  end

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

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

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(&: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



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

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(&: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



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

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(&: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)


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

def ast_contents
  [
    @attr.to_ast,
    @alignment.to_ast,
    @rowspan.to_ast,
    @colspan.to_ast,
    @children.map(&:to_ast)
  ]
end

#to_astHash

Create an AST representation of this Node

Returns:

  • (Hash)


72
73
74
# File 'lib/paru/filter/cell.rb', line 72

def to_ast
  ast_contents
end