Convert integers to short, human-scannable alphanumeric strings (skipping 'l', '1', 'o', '0', etc.) and back.
Unlike the code behind url shorteners, this supports case-insensitive conversion and omits letters and numbers that are difficult to distinguish by sight (like 'l' and '1')
# 45.human_code # => '3G' # 5234233.human_code # '7PQP9' # 'AYH783XM3AJZ99'.human_code # => 218567976681298046129 # 218567976681298046129.human_code # => 'AYH783XM3AJZ99' # ## strings that weren't generated by this library don't get converted # # "ajYz2".human_code # => "ajyz2" # ## But your users shouldn't have to use the shift key # # 'AJYZ2'.human_code # => 7893623 # "ajYz2".human_code :fix_case => true # => 7893623
* sudo gem install human_codes
This project was inspired by my and Mike Mondragon's alphadecimal, Shane Becker's NewBase60, and busy retail workers everywhere who need to enter coupon codes.
(The MIT License)
Copyright (c) 2010 Jack Danger Canty
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.