Class: Gotenberg::Utilities::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/gotenberg/utilities/index.rb

Class Method Summary collapse

Class Method Details

.to_alpha(index, alpha = '') ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/gotenberg/utilities/index.rb', line 4

def self.to_alpha index, alpha = ''
  return '' if index <= 0

  until index.zero?
    pointer = (index - 1) % 26
    index = ((index - pointer) / 26).to_i
    alpha = (65 + pointer).chr + alpha
  end
  
  alpha
end