Sha256: 1faaaad6efb0caeda8d4234aac50a4488d3867281d2d5bcced3f16bc7e8f956b

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

if RUBY_VERSION.to_f >= 2

  module SpreadsheetArchitect
    module AxlsxColumnWidthPatch
      def initialize(*args)
        @width = nil
        super
      end

      def width=(v)
        if v.nil?
          @custom_width = false
          @width = nil
        elsif @width.nil? || @width < v+5
          @custom_width = true
          @best_fit = true
          @width = v + 5
        else
          @custom_width = true
          @width = v
        end
      end
    end
  end

  module Axlsx
    class Col
      prepend ::SpreadsheetArchitect::AxlsxColumnWidthPatch
    end
  end

else

  module Axlsx
    class Col
      original_initialize = instance_method(:initialize)
      define_method :initialize do |*args|
        @width = nil

        original_initialize.bind(self).(*args)
      end

      def width=(v)
        if v.nil?
          @custom_width = false
          @width = nil
        elsif @width.nil? || @width < v+5
          @custom_width = true
          @best_fit = true
          @width = v + 5
        end
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spreadsheet_architect-3.3.1 lib/spreadsheet_architect/monkey_patches/axlsx_column_width.rb
spreadsheet_architect-3.3.0 lib/spreadsheet_architect/monkey_patches/axlsx_column_width.rb
spreadsheet_architect-3.2.1 lib/spreadsheet_architect/monkey_patches/axlsx_column_width.rb
spreadsheet_architect-3.2.0 lib/spreadsheet_architect/monkey_patches/axlsx_column_width.rb
spreadsheet_architect-3.1.0 lib/spreadsheet_architect/monkey_patches/axlsx_column_width.rb