Sha256: 2ffdeec5ee477c1e900d29f05472a257af36c77dacca0838222e57cfa9b17b77
Contents?: true
Size: 920 Bytes
Versions: 1
Compression:
Stored size: 920 Bytes
Contents
=Anybase ==Arbitrary number bases So often, I need to create random number bases, with random digits, to satisfy some crazy requirement. Here is an example of how you'd do hex in Anybase. base = Anybase.new('0123456789abcdef') base.to_i('f0a') => 3850 base.to_native(123450) => "1e23a" As well, you can tell Anybase to ignore case. base = Anybase.new('0123456789abcdef', :ignore_case => true) base.to_i('F0A') => 3850 Anybase can also zeropad your output with whatever your "zero" character is. Anybase.new("012345678").to_native(1234, :zero_pad => 8) => '00001621' Anybase gives you a few built-in: <tt>Anybase::Hex</tt>, <tt>Anybase::Base64</tt>, <tt>Anybase::Base64ForURL</tt> and <tt>Anybase::Base62</tt> (should all be pretty self-explanatory) As well, there is an <tt>AnyBase::Base66ForURL</tt>. This includes <tt>.</tt> and <tt>~</tt> as well as the usual base64 url safe characters.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
anybase-0.0.4 | README.rdoc |