Class: Bloomed::PW
- Inherits:
-
Object
- Object
- Bloomed::PW
- Includes:
- MsgPackable::Bloomed
- Defined in:
- lib/bloomed.rb
Instance Attribute Summary collapse
-
#bloom ⇒ Object
readonly
Returns the value of attribute bloom.
-
#cache_dir ⇒ Object
readonly
Returns the value of attribute cache_dir.
-
#false_positive_probability ⇒ Object
readonly
Returns the value of attribute false_positive_probability.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#top ⇒ Object
readonly
Returns the value of attribute top.
Instance Method Summary collapse
-
#initialize(top: 100_000, false_positive_probability: 0.001, cache_dir: nil) ⇒ PW
constructor
A new instance of PW.
- #memory_size_bytes ⇒ Object
- #pwned?(pw) ⇒ Boolean
Methods included from MsgPackable::Bloomed
#from_msgpack_ext, included, #to_msgpack, #to_msgpack_ext
Constructor Details
#initialize(top: 100_000, false_positive_probability: 0.001, cache_dir: nil) ⇒ PW
18 19 20 21 22 23 24 25 |
# File 'lib/bloomed.rb', line 18 def initialize(top: 100_000, false_positive_probability: 0.001, cache_dir: nil) @cache_dir = cache_dir || File.join(File.dirname(__FILE__), "dump") @top = top @false_positive_probability = false_positive_probability @bloom = prepare end |
Instance Attribute Details
#bloom ⇒ Object (readonly)
Returns the value of attribute bloom.
12 13 14 |
# File 'lib/bloomed.rb', line 12 def bloom @bloom end |
#cache_dir ⇒ Object (readonly)
Returns the value of attribute cache_dir.
12 13 14 |
# File 'lib/bloomed.rb', line 12 def cache_dir @cache_dir end |
#false_positive_probability ⇒ Object (readonly)
Returns the value of attribute false_positive_probability.
12 13 14 |
# File 'lib/bloomed.rb', line 12 def false_positive_probability @false_positive_probability end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
12 13 14 |
# File 'lib/bloomed.rb', line 12 def filename @filename end |
#top ⇒ Object (readonly)
Returns the value of attribute top.
12 13 14 |
# File 'lib/bloomed.rb', line 12 def top @top end |
Instance Method Details
#memory_size_bytes ⇒ Object
31 32 33 34 |
# File 'lib/bloomed.rb', line 31 def memory_size_bytes require "objspace" ObjectSpace.memsize_of(@bloom) end |
#pwned?(pw) ⇒ Boolean
27 28 29 |
# File 'lib/bloomed.rb', line 27 def pwned?(pw) @bloom.include?(Digest::SHA1.hexdigest(pw).upcase) end |