Sha256: 23578b0d43ce903b720e8a8a1447297f9c9ffc7234ad44da8afac9b8337d3001

Contents?: true

Size: 939 Bytes

Versions: 4

Compression:

Stored size: 939 Bytes

Contents

# frozen_string_literal: true

module Axlsx
  # A simple, self serializing class for storing tables
  class Tables < SimpleTypedList
    # creates a new Tables object
    def initialize(worksheet)
      raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)

      super(Table)
      @worksheet = worksheet
    end

    # The worksheet that owns this collection of tables
    # @return [Worksheet]
    attr_reader :worksheet

    # returns the relationships required by this collection
    def relationships
      return [] if empty?

      map { |table| Relationship.new(table, TABLE_R, "../#{table.pn}") }
    end

    # renders the tables xml
    # @param [String] str
    # @return [String]
    def to_xml_string(str = +'')
      return if empty?

      str << "<tableParts count='#{size}'>"
      each { |table| str << "<tablePart r:id='#{table.rId}'/>" }
      str << '</tableParts>'
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/workbook/worksheet/tables.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/workbook/worksheet/tables.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/workbook/worksheet/tables.rb
caxlsx-4.1.0 lib/axlsx/workbook/worksheet/tables.rb