Skip to content

Commit

Permalink
use BloomFilter::ConfigurationMismatch instead of ArgumentError
Browse files Browse the repository at this point in the history
  • Loading branch information
William Watson committed Apr 27, 2012
1 parent ba20cc9 commit 76c1dcd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/bloomfilter/native.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module BloomFilter
BloomFilter::ConfigurationMismatch = Class.new(ArgumentError)

class Native < Filter
attr_reader :bf

def initialize(opts = {})
@opts = {
:size => 100,
Expand Down Expand Up @@ -45,7 +47,7 @@ def set_bits
# It assumes that both filters have the same size -
# if this is not true +ArgumentError+ is raised.
def &(o)
raise ArgumentError.new() unless same_parameters?(o)
raise BloomFilter::ConfigurationMismatch.new unless same_parameters?(o)
result = self.class.new
result.instance_variable_set(:@bf,@bf.&(o.bf))
result
Expand All @@ -55,7 +57,7 @@ def &(o)
# It assumes that both filters have the same size -
# if this is not true +ArgumentError+ is raised.
def |(o)
raise ArgumentError.new() unless same_parameters?(o)
raise BloomFilter::ConfigurationMismatch.new unless same_parameters?(o)
result = self.class.new
result.instance_variable_set(:@bf,@bf.|(o.bf))
result
Expand Down
2 changes: 1 addition & 1 deletion spec/native_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
bf2 = Native.new(:size => 20)
bf2.insert("test")

proc {bf1 & bf2}.should raise_error(ArgumentError)
proc {bf1 & bf2}.should raise_error(BloomFilter::ConfigurationMismatch)
end

it "should return union with other filter" do
Expand Down

0 comments on commit 76c1dcd

Please sign in to comment.