Sha256: b5cd1f992d87cecd6b94b72f4aacfdcb7a4dc41cfbecf5ff4092835e7e174ac6

Contents?: true

Size: 375 Bytes

Versions: 9

Compression:

Stored size: 375 Bytes

Contents

# frozen_string_literal: false

module Kiev
  module Base52
    KEYS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".freeze
    BASE = KEYS.length

    def self.encode(num)
      return KEYS[0] if num == 0
      return nil if num < 0

      str = ""
      while num > 0
        str.prepend(KEYS[num % BASE])
        num /= BASE
      end
      str
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kiev-4.9.0 lib/kiev/base52.rb
kiev-4.8.3 lib/kiev/base52.rb
kiev-4.8.2 lib/kiev/base52.rb
kiev-4.8.1 lib/kiev/base52.rb
kiev-4.8.0 lib/kiev/base52.rb
kiev-4.7.0 lib/kiev/base52.rb
kiev-4.6.0 lib/kiev/base52.rb
kiev-4.5.0 lib/kiev/base52.rb
kiev-4.4.0 lib/kiev/base52.rb