summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-17 00:24:29 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-17 00:30:59 +0100
commit1fddc1eb2dde85b5909b90c77656bee6eb500298 (patch)
treeb07d519e42c883723c44ec734d1144f3cabf408e
parentd61de70f15e57f20b99cd4993ded2fd802997d0b (diff)
filters: don't force data types in @bot.filter()
-rw-r--r--lib/rbot/core/utils/filters.rb20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/rbot/core/utils/filters.rb b/lib/rbot/core/utils/filters.rb
index 4a831497..2da89d08 100644
--- a/lib/rbot/core/utils/filters.rb
+++ b/lib/rbot/core/utils/filters.rb
@@ -64,22 +64,16 @@ module ::Irc
#
def filter(*args)
@filters ||= {}
- case args.last
- when DataStream
- # the stream is an actual DataStream
- ds = args.pop
- when String
- # the stream is just plain text
- ds = DataStream.new(args.pop)
- when Hash
- # the stream is a Hash, check if the previous element is a String
- if String === args[-2]
- ds = DataStream.new(*args.slice!(-2, 2))
- else
+ if Hash === args.last
+ # the stream is a Hash, check if the previous element is not a Symbol
+ if Symbol === args[-2]
ds = DataStream.new(args.pop)
+ else
+ ds = DataStream.new(*args.slice!(-2, 2))
end
else
- raise "Unknown DataStream class #{args.last.class}"
+ # the stream is just whatever else
+ ds = DataStream.new(args.pop)
end
names = args.dup
return ds if names.empty?