Module: Alphadecimal::Number
Instance Method Summary collapse
Instance Method Details
#alphadecimal ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/alphadecimal.rb', line 14 def alphadecimal return self if nil? || self < 0 return to_s if self == 0 string = "" value = self until value == 0 case mod = value % 62 when 0..9 then string << (mod + B62_0) when 10..35 then string << (mod - 10 + B62_A) when 36...62 then string << (mod - 36 + B62_a) end value = value / 62 end string.reverse end |