Method: Voltron::Encrypt#encode
- Defined in:
- lib/voltron/encrypt.rb
#encode(input) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/voltron/encrypt.rb', line 10 def encode(input) radix = digits.length i = input.to_i + Voltron.config.encrypt.offset.to_i # Increase the number just so we don't end up with id's like "E" or "d3" on low number ids raise ArgumentError.new("Value #{val} cannot be less than zero") if i < 0 out = [] begin rem = i % radix i /= radix out << digits[rem] end until i == 0 out.reverse.join end |