lib/spidr/rules.rb in spidr-0.3.1 vs lib/spidr/rules.rb in spidr-0.3.2

- old
+ new

@@ -38,21 +38,13 @@ # Specifies whether the given data was accepted, using the rules # acceptance patterns. # def accept?(data) unless @accept.empty? - @accept.each do |rule| - return true if test_data(data,rule) - end - - return false + @accept.any? { |rule| test_data(data,rule) } else - @reject.each do |rule| - return false if test_data(data,rule) - end - - return true + !@reject.any? { |rule| test_data(data,rule) } end end # # Determines whether the data should be rejected or accepted. @@ -60,11 +52,11 @@ # @return [Boolean] # Specifies whether the given data was rejected, using the rules # rejection patterns. # def reject?(data) - !(accept?(data)) + !accept?(data) end protected # @@ -73,14 +65,14 @@ # @return [Boolean] # Specifies whether the given data matched the pattern. # def test_data(data,rule) if rule.kind_of?(Proc) - return (rule.call(data) == true) + rule.call(data) == true elsif rule.kind_of?(Regexp) - return !((data.to_s =~ rule).nil?) + !((data.to_s =~ rule).nil?) else - return data == rule + data == rule end end end end