From 1fddc1eb2dde85b5909b90c77656bee6eb500298 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 17 Mar 2008 00:24:29 +0100 Subject: filters: don't force data types in @bot.filter() --- lib/rbot/core/utils/filters.rb | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'lib/rbot') 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? -- cgit v1.2.3