Sha256: 872d1c6e7dcac1938eccaedd231098a504314dc16f4aa3d9550cdd99291e4115

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Axlsx
  # A collection of Brake objects.
  # Please do not use this class directly. Instead use
  # Worksheet#add_break
  class ColBreaks < SimpleTypedList
    # Instantiates a new list restricted to Break types
    def initialize
      super(Break)
    end

    # A column break specific helper for adding a break.
    # @param [Hash] options A list of options to pass into the Break object
    # The max and man options are fixed, however any other valid option for
    # Break will be passed to the created break object.
    # @see Break
    def add_break(options)
      self << Break.new(options.merge(max: 1048575, man: true))
      last
    end

    # Serialize the collection to xml
    # @param [String] str The string to append this lists xml to.
    # <colBreaks count="1" manualBreakCount="1">
    # <brk id="3" max="1048575" man="1"/>
    # </colBreaks>
    def to_xml_string(str = +'')
      return if empty?

      str << '<colBreaks count="' << size.to_s << '" manualBreakCount="' << size.to_s << '">'
      each { |brk| brk.to_xml_string(str) }
      str << '</colBreaks>'
    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/col_breaks.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/workbook/worksheet/col_breaks.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/workbook/worksheet/col_breaks.rb
caxlsx-4.1.0 lib/axlsx/workbook/worksheet/col_breaks.rb