Sha256: b5e1f10e0d28e53a4b53aeccfcb8b240a5d1b3495ef35749ac5d68ea675a475a

Contents?: true

Size: 221 Bytes

Versions: 2

Compression:

Stored size: 221 Bytes

Contents

class String
  
  Alpha26 = ("a".."z").to_a

  def to_i26
    result = 0
    downcase!
    (1..length).each do |i|
      char = self[-i]
      result += 26**(i-1) * (Alpha26.index(char) + 1)
    end
    result
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
creative_rails_utilities-0.1.1 lib/creative_rails_utilities/string.rb
creative_rails_utilities-0.1.0 lib/creative_rails_utilities/string.rb