Module: Tokenie
- Defined in:
- lib/tokenie.rb,
lib/tokenie/version.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
-
.friendly(options = {}) ⇒ Object
Generates a friendly string randomically.
Class Method Details
.friendly(options = {}) ⇒ Object
Generates a friendly string randomically
6 7 8 9 10 11 12 13 14 |
# File 'lib/tokenie.rb', line 6 def self.friendly( = {}) length = [:length] || 6 raise ArgumentError, "'length' must be in range (2..16)" if length < 2 || length > 16 loop do token = SecureRandom.base64(15).tr('+/=1lIO0o', 'abcdefghj')[0, length] break token unless block_given? && yield(token) end end |