Class: Util::Base
- Inherits:
-
Object
- Object
- Util::Base
- Defined in:
- lib/record-locator-util.rb
Class Method Summary collapse
Class Method Details
.decode(string) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/record-locator-util.rb', line 27 def self.decode(string) string = string.to_s return string if string.split('').include?('1') || string.split('').include?('0') # as 0 and 1 are included into exceptional chars ring = Util::DECODER[Util::BASE27] base = Util::BASE27.length string.reverse.chars.enum_for(:each_with_index).inject(0) do |sum,(char,i)| sum + ring[char] * base**i end end |