]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/utils/extends.rb
config core botmodule: only show possible keys summary when more than one key was...
[user/henk/code/ruby/rbot.git] / lib / rbot / core / utils / extends.rb
index f3861745442035ebb60e926b61188ec3c0d5aec8..e62e2f21ea768ec846a7b607020ecaf6c4d9cf73 100644 (file)
@@ -4,8 +4,6 @@
 # :title: Standard classes extensions
 #
 # Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
-# Copyright:: (C) 2006,2007 Giuseppe Bilotta
-# License:: GPL v2
 #
 # This file collects extensions to standard Ruby classes and to some core rbot
 # classes to be used by the various plugins
@@ -109,6 +107,24 @@ class ::Array
     end
     self.delete_at(index)
   end
+
+  # This method shuffles the items in the array
+  def shuffle!
+    base = self.dup
+    self.clear
+    while item = base.delete_one
+      self << item
+    end
+    self
+  end
+
+  # This method returns a new array with the same items as
+  # the receiver, but shuffled
+  def shuffle
+    ret = self.dup
+    ret.shuffle!
+  end
+
 end
 
 # Extensions to the Range class