summaryrefslogtreecommitdiff
path: root/lib/trocla/util.rb
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2011-07-27 18:43:55 +0200
committermh <mh@immerda.ch>2011-07-27 18:43:55 +0200
commit9146a541ff96b92f4f14c6292307b68dc4673097 (patch)
tree3637ab49056565fad3566d78698634c2a6ab7265 /lib/trocla/util.rb
initial release of trocla
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