to_insane is a Ruby library/gem for converting ints above 36 and lets you use your own character sets
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 13 commits ahead of dougal:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
CHANGELOG
MIT-LICENSE
README.rdoc
Rakefile
VERSION
to_insane.gemspec

README.rdoc

To Insane!

A small String and Integer extender that allow you to use a base larger than 36 and use custom character sets for base conversion. Default max of 67. Also include url safe integer conversion.

Donate

I did not really make this library I just modified it off this guy. Donate your money to him.

If you find this library useful, please consider a donation to show your support!

www.paypal.com/cgi-bin/webscr?cmd=_send-money

Paypal address: dougal.s@gmail.com

Install

$ sudo gem install to_insane

Usage

require 'rubygems'
require 'to_insane'

# Int to insane (Default: Base 58)
1337.to_insane # => n3

# From insane to Int (Default: Base 58)
'A2Ph'.from_insane # => 7033619

# Different Bases
'A2Ph'.from_insane(50) # => 4507467
4507467.to_insane(50)  # => 'A2Ph'

# Different Character Sets
'A2Ph'.from_insane(:max,'A2Ph') # => 27
27.to_insane(:max,'A2Ph')

# Other Inputs
# :url_safe uses the max number characters that are RFC URL non reserved
# :max uses the max number of characters for given character set. Default character set is 87
27.to_insane(:url_safe) 
27.to_insane(:max)

Info

Default Character set. I choose not to use any slashes or quotes of any sort to prevent breaking

INSANECHARACTERS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ-._~+[]|$!*(),{}^<>#%;?:@&='

Credits

Ryan Ong - ryangong.net

Douglas F Shearer - douglasfshearer.com

Developed for and with CarZen.com