]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
ruby 1.9: get rid of Array#nitems
authorfranz <Franz.Netykafka@runbox.com>
Mon, 15 Jun 2009 18:41:01 +0000 (20:41 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 26 Aug 2009 21:31:36 +0000 (23:31 +0200)
Array#nitems is gone in ruby 1.9, changed rbot code to use
Array.compact.size, which works in both 1.8 & 1.9

data/rbot/plugins/quotes.rb
lib/rbot/core/remote.rb

index bb5ae57e04e4cc2bbeba8a57225d4f20b917e355..c10666899b0024369f04f2610b87d6e358d6b90b 100644 (file)
@@ -80,7 +80,7 @@ class QuotePlugin < Plugin
       end
     else
       # random quote
-      return @lists[channel].compact[rand(@lists[channel].nitems)],
+      return @lists[channel].compact.pick_one,
       @lists[channel].length - 1
     end
   end
index 2d39d7696b3466be543ca49d2cc36da8b312df92..0cefae265a3c7dbba0b0e281d93531464790f5d8 100644 (file)
@@ -136,7 +136,7 @@ class Bot
       raise "Botmodule #{botmodule.name} tried to unmap #{tmpl.inspect} that was handled by #{tmpl.botmodule}" unless tmpl.botmodule == botmodule.name
       debug "Unmapping #{tmpl.inspect}"
       @templates[handle] = nil
-      @templates.clear unless @templates.nitems > 0
+      @templates.clear unless @templates.compact.size > 0
     end
 
     # We redefine the handle() method from MessageMapper, taking into account