Created
January 28, 2014 12:05
-
-
Save sklppr/8666521 to your computer and use it in GitHub Desktop.
Coupon code generator with customizable number of parts, number of characters per part and separator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def coupon(parts: 4, chars: 4, separator: "-") | |
SecureRandom.hex(parts*chars/2).upcase.scan(%r/.{#{chars}}/).join(separator) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment