Class: Trocla::Util

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

Overview

Utils

Class Method Summary collapse

Class Method Details

.random_str(length = 12, charset = 'default') ⇒ Object



6
7
8
9
10
# File 'lib/trocla/util.rb', line 6

def random_str(length = 12, charset = 'default')
  char = charsets[charset] || charsets['default']
  charsets_size = char.size
  (1..length).collect { |_| char[rand_num(charsets_size)] }.join.to_s
end

.salt(length = 8) ⇒ Object



12
13
14
# File 'lib/trocla/util.rb', line 12

def salt(length = 8)
  random_str(length, 'alphanumeric')
end