summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet/cols.rb
blob: 7dd3f175107ffe10da98de0befbcc01cd5f731e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module Axlsx
  # The cols class manages the col object used to manage column widths.
  # This is where the magic happens with autowidth
  class Cols < SimpleTypedList
    def initialize(worksheet)
      raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)

      super Col
      @worksheet = worksheet
    end

    # Serialize the Cols object
    # @param [String] str
    # @return [String]
    def to_xml_string(str = +'')
      return if empty?

      str << '<cols>'
      each { |item| item.to_xml_string(str) }
      str << '</cols>'
    end
  end
end