Class: WordBloom::FilterBuilder
- Inherits:
-
Object
- Object
- WordBloom::FilterBuilder
- Defined in:
- lib/word-bloom/filter-builder.rb
Constant Summary collapse
- BITFIELD_WIDTH =
2_000_000
Instance Method Summary collapse
- #filter_from_dictionary ⇒ Object
-
#initialize(source_path) ⇒ FilterBuilder
constructor
A new instance of FilterBuilder.
Constructor Details
#initialize(source_path) ⇒ FilterBuilder
Returns a new instance of FilterBuilder.
5 6 7 |
# File 'lib/word-bloom/filter-builder.rb', line 5 def initialize(source_path) @filename = source_path end |
Instance Method Details
#filter_from_dictionary ⇒ Object
9 10 11 12 13 |
# File 'lib/word-bloom/filter-builder.rb', line 9 def filter_from_dictionary filter = BloominSimple.new(BITFIELD_WIDTH, &HASHER) File.open(@filename).each { |word| filter.add(word) } filter end |