Class: Bloomin::Filter
- Inherits:
-
Object
- Object
- Bloomin::Filter
- Defined in:
- lib/bloomin/filter.rb
Instance Attribute Summary collapse
-
#bloom ⇒ Object
readonly
Returns the value of attribute bloom.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Filter
constructor
A new instance of Filter.
- #is_word?(word) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ Filter
Returns a new instance of Filter.
8 9 10 11 12 13 |
# File 'lib/bloomin/filter.rb', line 8 def initialize(opts = {}) @size = opts[:size] || 5000000 @bloom = Array.new(self.size).fill(0) load_words end |
Instance Attribute Details
#bloom ⇒ Object (readonly)
Returns the value of attribute bloom.
5 6 7 |
# File 'lib/bloomin/filter.rb', line 5 def bloom @bloom end |
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/bloomin/filter.rb', line 6 def size @size end |
Instance Method Details
#is_word?(word) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bloomin/filter.rb', line 15 def is_word?(word) integers = hash(word) integers.each do |i| if self.bloom[i] == 0 puts "not a word - #{word}" if debug? false else puts "probably, a word - #{word}, #{probability}" if debug? true end end end |