Class: Coradoc::AsciiDoc::Model::TableCell
- Includes:
- Anchorable
- Defined in:
- lib/coradoc/asciidoc/model/table_cell.rb
Overview
Instance Attribute Summary collapse
-
#alignattr ⇒ String
readonly
Legacy alignment string (for serialization).
-
#colrowattr ⇒ String
readonly
Legacy combined colspan.rowspan string (for serialization).
-
#colspan ⇒ Integer?
readonly
Number of columns to span.
-
#content ⇒ Array<TextElement>
readonly
Cell content.
-
#halign ⇒ String?
readonly
Horizontal alignment: “<” left, “^” center, “>” right.
-
#id ⇒ String?
readonly
Optional cell identifier.
-
#repeat ⇒ Boolean
readonly
Whether to repeat last cell.
-
#rowspan ⇒ Integer?
readonly
Number of rows to span.
-
#style ⇒ String?
readonly
Cell style: d/s/e/m/a/l/v.
-
#valign ⇒ String?
readonly
Vertical alignment: “<” top, “^” middle, “>” bottom.
Instance Method Summary collapse
-
#asciidoc? ⇒ Boolean
Check if this cell contains AsciiDoc content.
-
#generate_alignattr ⇒ String
Generate alignattr for serialization (e.g., “^” for center).
-
#generate_colrowattr ⇒ String
Generate colrowattr for serialization (e.g., “2.3” for colspan=2, rowspan=3).
-
#horizontal_alignment ⇒ String?
Get horizontal alignment as CSS value.
-
#literal? ⇒ Boolean
Check if this cell has literal content.
-
#style_name ⇒ String?
Get style name as human-readable string.
-
#verse? ⇒ Boolean
Check if this cell has verse style.
-
#vertical_alignment ⇒ String?
Get vertical alignment as CSS value.
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
#alignattr ⇒ String (readonly)
Returns 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 |
#colrowattr ⇒ String (readonly)
Returns 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 |
#colspan ⇒ Integer? (readonly)
Returns 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 |
#content ⇒ Array<TextElement> (readonly)
Returns Cell content.
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 |
#halign ⇒ String? (readonly)
Returns 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 |
#id ⇒ String? (readonly)
Returns 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 |
#repeat ⇒ Boolean (readonly)
Returns 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 |
#rowspan ⇒ Integer? (readonly)
Returns 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 |
#style ⇒ String? (readonly)
Returns 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 |
#valign ⇒ String? (readonly)
Returns 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
57 58 59 |
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 57 def asciidoc? style == 'a' end |
#generate_alignattr ⇒ String
Generate alignattr for serialization (e.g., “^” for center)
116 117 118 |
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 116 def generate_alignattr (halign || '') + (valign || '') end |
#generate_colrowattr ⇒ String
Generate colrowattr for serialization (e.g., “2.3” for colspan=2, rowspan=3)
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_alignment ⇒ String?
Get horizontal alignment as CSS value
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
62 63 64 |
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 62 def literal? style == 'l' end |
#style_name ⇒ String?
Get style name as human-readable string
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
67 68 69 |
# File 'lib/coradoc/asciidoc/model/table_cell.rb', line 67 def verse? style == 'v' end |
#vertical_alignment ⇒ String?
Get vertical alignment as CSS value
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 |