diff --git a/Gemfile b/Gemfile index 024907d..e14bdcf 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gem 'rails', '~> 4.0.0.beta1' gem 'pg' -gem 'radix', '~>2.1.1' +gem 'radix', '~>2.1.1', require: 'radix/integer' gem 'rake', '~>10.0.4' diff --git a/lib/number_encoder.rb b/lib/number_encoder.rb index 455dff2..8f0c08c 100644 --- a/lib/number_encoder.rb +++ b/lib/number_encoder.rb @@ -6,7 +6,7 @@ def self.encode(number) # Ensure that codes are sparse by ensuring the last two characters of the base 'n' number # are different for encode(n) and encode(n + 1) number = number * (ALPHABET.length + 1) - number.b(ALPHABET).to_s + Radix::Integer.new(number).to_s(ALPHABET) end def self.normalize(code)