Module: Comfan

Extended by:
Comfan
Included in:
Comfan
Defined in:
lib/comfan.rb,
lib/comfan/version.rb

Constant Summary collapse

VERSION =
'0.1.1'

Instance Method Summary collapse

Instance Method Details

#api_id(input_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/comfan.rb', line 6

def api_id input_id
  return input_id if input_id.nil? || 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

#ui_id(input_id) ⇒ Object



23
24
25
26
27
# File 'lib/comfan.rb', line 23

def ui_id input_id
  return input_id if input_id.nil? || input_id.length <= 15

  input_id[0..-4]
end