Sha256: 79ad827e3bda539f0a7d390f21d881a71def8a32003ee511b3ffee9beef5f2b0

Contents?: true

Size: 527 Bytes

Versions: 1

Compression:

Stored size: 527 Bytes

Contents

require "comfan/version"

module Comfan
  extend self

  def api_id input_id
    return input_id if input_id.length >= 18
    suffix = ''
 
    3.times do |i|
      flags = 0
      5.times do |j|
        c = input_id[i * 5 + j]
        if c.upcase == c && c >= 'A' && c <= 'Z'
          flags = flags + ( 1 << j )
        end
      end
      suffix += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345'[flags]
    end
    input_id + suffix
  end

  def ui_id input_id
    return input_id if input_id.length <= 15

    input_id[0..-4]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comfan-0.1.0 lib/comfan.rb