Sha256: d07eea2449610cedff56a3e6dc73e777a50cd698f29be26373c55bcb77eca4c7

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

require 'berkeley_library/util/ods/xml/table/repeatable'
require 'berkeley_library/util/ods/xml/text/p'

module BerkeleyLibrary
  module Util
    module ODS
      module XML
        module Table
          class TableCell < Repeatable
            attr_reader :value
            attr_reader :cell_style

            def initialize(value = nil, cell_style = nil, number_repeated = 1, table:)
              super('table-cell', 'number-columns-repeated', number_repeated, table: table)

              @value = value
              @cell_style = cell_style

              set_default_attributes!
              add_default_children!
            end

            class << self
              def repeat_empty(number_repeated, cell_style = nil, table:)
                TableCell.new(nil, cell_style, number_repeated, table: table)
              end
            end

            private

            def set_default_attributes!
              set_attribute('style-name', cell_style.style_name) if cell_style
              set_attribute(:office, 'value-type', 'string') if value
              set_attribute(:calcext, 'value-type', 'string') if value
            end

            def add_default_children!
              children << XML::Text::P.new(value, doc: doc) if value
            end

          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
berkeley_library-tind-0.7.2 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.7.1 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.7.0 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.6.0 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.5.1 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.5.0 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.4.3 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.4.2 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.4.1 lib/berkeley_library/util/ods/xml/table/table_cell.rb
berkeley_library-tind-0.4.0 lib/berkeley_library/util/ods/xml/table/table_cell.rb