Sha256: a28b735b4157263f20400ba07f17a67f9997630d063e144803152382c5506a9c

Contents?: true

Size: 352 Bytes

Versions: 6

Compression:

Stored size: 352 Bytes

Contents

# frozen_string_literal: true
module Saxlsx
  class ColumnNameGenerator
    FIRST = 'A'
    LAST  = 'Z'

    def self.next_to(previous)
      char = previous ? previous[-1] : nil
      if char.nil?
        FIRST
      elsif char < LAST
        previous[0..-2] + char.next
      else
        next_to(previous[0..-2]) + FIRST
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
saxlsx-1.11.0 lib/saxlsx/column_name_generator.rb
saxlsx-1.10.0 lib/saxlsx/column_name_generator.rb
saxlsx-1.9.0 lib/saxlsx/column_name_generator.rb
saxlsx-1.8.0 lib/saxlsx/column_name_generator.rb
saxlsx-1.7.1 lib/saxlsx/column_name_generator.rb
saxlsx-1.7.0 lib/saxlsx/column_name_generator.rb