Class: Coradoc::AsciiDoc::Model::TableCell

Inherits:
Base
  • Object
show all
Includes:
Anchorable
Defined in:
lib/coradoc/asciidoc/model/table_cell.rb

Overview

Table cell with full AsciiDoc format specification support

Cell format specification: [colspan][halign][style]

Examples:

Cell spanning 2 columns

cell = TableCell.new(content: "text", colspan: 2)

Centered cell with emphasis style

cell = TableCell.new(content: "text", halign: "^", style: "e")

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Anchorable

#default_anchor, #gen_anchor, included, #initialize

Methods inherited from Base

#block_level?, #inline?, #serialize_content, #simplify_block_content, #to_adoc, #to_h, visit, #visit

Instance Attribute Details

#alignattrString (readonly)

Returns Legacy alignment string (for serialization).

Returns:

  • (String)

    Legacy alignment string (for serialization)



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#colrowattrString (readonly)

Returns Legacy combined colspan.rowspan string (for serialization).

Returns:

  • (String)

    Legacy combined colspan.rowspan string (for serialization)



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#colspanInteger? (readonly)

Returns Number of columns to span.

Returns:

  • (Integer, nil)

    Number of columns to span



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#contentArray<TextElement> (readonly)

Returns Cell content.

Returns:



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#halignString? (readonly)

Returns Horizontal alignment: “<” left, “^” center, “>” right.

Returns:

  • (String, nil)

    Horizontal alignment: “<” left, “^” center, “>” right



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#idString? (readonly)

Returns Optional cell identifier.

Returns:

  • (String, nil)

    Optional cell identifier



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#repeatBoolean (readonly)

Returns Whether to repeat last cell.

Returns:

  • (Boolean)

    Whether to repeat last cell



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#rowspanInteger? (readonly)

Returns Number of rows to span.

Returns:

  • (Integer, nil)

    Number of rows to span



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#styleString? (readonly)

Returns Cell style: d/s/e/m/a/l/v.

Returns:

  • (String, nil)

    Cell style: d/s/e/m/a/l/v



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

#valignString? (readonly)

Returns Vertical alignment: “<” top, “^” middle, “>” bottom.

Returns:

  • (String, nil)

    Vertical alignment: “<” top, “^” middle, “>” bottom



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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 37

class TableCell < Base
  include Coradoc::AsciiDoc::Model::Anchorable

  # Core attributes
  attribute :id, :string
  attribute :content, Coradoc::AsciiDoc::Model::TextElement, collection: true, initialize_empty: true

  # Cell format specification attributes
  attribute :colspan, :integer
  attribute :rowspan, :integer
  attribute :halign, :string  # "<" left, "^" center, ">" right
  attribute :valign, :string  # "<" top, "^" middle, ">" bottom
  attribute :style, :string   # d/s/e/m/a/l/v
  attribute :repeat, :boolean, default: -> { false }

  # Legacy attributes for backward compatibility with serializer
  attribute :colrowattr, :string, default: -> { '' }
  attribute :alignattr, :string, default: -> { '' }

  # Check if this cell contains AsciiDoc content
  def asciidoc?
    style == 'a'
  end

  # Check if this cell has literal content
  def literal?
    style == 'l'
  end

  # Check if this cell has verse style
  def verse?
    style == 'v'
  end

  # Get horizontal alignment as CSS value
  # @return [String, nil] "left", "center", or "right"
  def horizontal_alignment
    case halign
    when '<' then 'left'
    when '^' then 'center'
    when '>' then 'right'
    end
  end

  # Get vertical alignment as CSS value
  # @return [String, nil] "top", "middle", or "bottom"
  def vertical_alignment
    case valign
    when '<' then 'top'
    when '^' then 'middle'
    when '>' then 'bottom'
    end
  end

  # Get style name as human-readable string
  # @return [String, nil] Style name
  def style_name
    case style
    when 'd' then 'default'
    when 's' then 'strong'
    when 'e' then 'emphasis'
    when 'm' then 'monospace'
    when 'a' then 'asciidoc'
    when 'l' then 'literal'
    when 'v' then 'verse'
    end
  end

  # Generate colrowattr for serialization (e.g., "2.3" for colspan=2, rowspan=3)
  # @return [String] Combined colspan.rowspan string
  def generate_colrowattr
    result = ''
    result += colspan.to_s if colspan && colspan > 1
    result += ".#{rowspan}" if rowspan && rowspan > 1
    result
  end

  # Generate alignattr for serialization (e.g., "^" for center)
  # @return [String] Combined alignment string
  def generate_alignattr
    (halign || '') + (valign || '')
  end
end

Instance Method Details

#asciidoc?Boolean

Check if this cell contains AsciiDoc content

Returns:

  • (Boolean)


57
58
59
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 57

def asciidoc?
  style == 'a'
end

#generate_alignattrString

Generate alignattr for serialization (e.g., “^” for center)

Returns:

  • (String)

    Combined alignment string



116
117
118
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 116

def generate_alignattr
  (halign || '') + (valign || '')
end

#generate_colrowattrString

Generate colrowattr for serialization (e.g., “2.3” for colspan=2, rowspan=3)

Returns:

  • (String)

    Combined colspan.rowspan string



107
108
109
110
111
112
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 107

def generate_colrowattr
  result = ''
  result += colspan.to_s if colspan && colspan > 1
  result += ".#{rowspan}" if rowspan && rowspan > 1
  result
end

#horizontal_alignmentString?

Get horizontal alignment as CSS value

Returns:

  • (String, nil)

    “left”, “center”, or “right”



73
74
75
76
77
78
79
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 73

def horizontal_alignment
  case halign
  when '<' then 'left'
  when '^' then 'center'
  when '>' then 'right'
  end
end

#literal?Boolean

Check if this cell has literal content

Returns:

  • (Boolean)


62
63
64
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 62

def literal?
  style == 'l'
end

#style_nameString?

Get style name as human-readable string

Returns:

  • (String, nil)

    Style name



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 93

def style_name
  case style
  when 'd' then 'default'
  when 's' then 'strong'
  when 'e' then 'emphasis'
  when 'm' then 'monospace'
  when 'a' then 'asciidoc'
  when 'l' then 'literal'
  when 'v' then 'verse'
  end
end

#verse?Boolean

Check if this cell has verse style

Returns:

  • (Boolean)


67
68
69
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 67

def verse?
  style == 'v'
end

#vertical_alignmentString?

Get vertical alignment as CSS value

Returns:

  • (String, nil)

    “top”, “middle”, or “bottom”



83
84
85
86
87
88
89
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 83

def vertical_alignment
  case valign
  when '<' then 'top'
  when '^' then 'middle'
  when '>' then 'bottom'
  end
end