summaryrefslogtreecommitdiff
path: root/lib/trocla/util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/trocla/util.rb')
-rw-r--r--lib/trocla/util.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/trocla/util.rb b/lib/trocla/util.rb
new file mode 100644
index 0000000..468206d
--- /dev/null
+++ b/lib/trocla/util.rb
@@ -0,0 +1,14 @@
+class Trocla
+ class Util
+ class << self
+ def random_str(length=12)
+ (1..length).collect{|a| chars[rand(chars.size)] }.join.to_s
+ end
+
+ private
+ def chars
+ @chars ||= (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a) + "+*%/()@&=?![]{}-_.,;:<>".split(//)
+ end
+ end
+ end
+end \ No newline at end of file