Class: RandomString
- Inherits:
-
Object
- Object
- RandomString
- Defined in:
- lib/audit/lib/util/random_string.rb
Class Method Summary collapse
- .generate(length = 20, alphabet = ('A' .. 'Z').to_a + ('a' .. 'z').to_a + ('0' .. '9').to_a) ⇒ Object
- .generate_name(length = 20) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ RandomString
constructor
A new instance of RandomString.
Constructor Details
#initialize ⇒ RandomString
Returns a new instance of RandomString.
22 23 |
# File 'lib/audit/lib/util/random_string.rb', line 22 def initialize end |
Class Method Details
.generate(length = 20, alphabet = ('A' .. 'Z').to_a + ('a' .. 'z').to_a + ('0' .. '9').to_a) ⇒ Object
25 26 27 |
# File 'lib/audit/lib/util/random_string.rb', line 25 def self.generate(length = 20, alphabet = ('A' .. 'Z').to_a + ('a' .. 'z').to_a + ('0' .. '9').to_a) return (0 .. length).map { alphabet.sec_sample }.join end |
.generate_name(length = 20) ⇒ Object
29 30 31 |
# File 'lib/audit/lib/util/random_string.rb', line 29 def self.generate_name(length = 20) return (('A' .. 'Z').to_a + ('a' .. 'z').to_a).sec_sample + generate(length - 1) end |