Class: RandomString

Inherits:
Object
  • Object
show all
Defined in:
lib/audit/lib/util/random_string.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRandomString

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