]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
#any? and #all? methods for Channel#mode to check if modes are set
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 22 Jun 2008 23:17:52 +0000 (01:17 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 22 Jun 2008 23:17:52 +0000 (01:17 +0200)
lib/rbot/irc.rb

index 31d432fd7c7af6a25b3fe712bcc92cb9a7fa5808..72579b1967ce6c07b442c5ab559391940cb84d39 100644 (file)
@@ -1358,6 +1358,14 @@ module Irc
 
       # Flags
       @mode = {}
+      class << @mode
+        def any?(*ar)
+          !!ar.find { |m| s = m.to_sym ; self[s] && self[s].set? }
+        end
+        def all?(*ar)
+          !ar.find { |m| s = m.to_sym ; !(self[s] && self[s].set?) }
+        end
+      end
     end
 
     # Removes a user from the channel