Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rand62/core_ext.rb
Constant Summary collapse
- BASE62_MAP =
Hash[Rand62::CHARS.map.with_index{|c,i| [c, i]
Instance Method Summary collapse
Instance Method Details
#base62 ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rand62/core_ext.rb', line 6 def base62 i = 0 i_out = 0 self.split(//).reverse.each do |c| place = 62 ** i i_out += BASE62_MAP[c] * place i += 1 end i_out end |