class Fzy::PreparedHaystack
- Fzy::PreparedHaystack
- Reference
- Object
Overview
This class should be used if you plan to do more than one search on the same haystack. It just cache some stuff making following searches faster.
haystack = %w(dog cat bat tiger)
prepared_haystack = PreparedHaystack.new(haystack)
Fzy.search(prepared_haystack).each do |match|
puts "found #{match.value} with score #{match.score}"
end
Usually you never need to use any methods from this object, just create it and call Fzy.search.
NOTE This class DO NOT dup the haystack it receive in the constructor, storing just a reference to it, so if you change it without creating another PreparedHaystack you are going to get a undefined behavior.
Defined in:
fzy/prepared_haystack.crConstructors
-
.new(haystack : Array(String))
Creates a new
PreparedHaystack.
Instance Method Summary
-
#any?(*args, **options)
Return true if haystack has some item.
-
#any?(*args, **options, &)
Return true if haystack has some item.
-
#bonus(index) : Array(Float32)
Return the cached bonus for a haystack at given index.
-
#empty?(*args, **options)
Return true if haystack is empty.
-
#empty?(*args, **options, &)
Return true if haystack is empty.
-
#haystack : Array(String)
Return the same haystack used in the constructor
-
#lower_haystack : Array(String)
Cached lowercase version of
#haystack. - #search(needle : String) : Array(Match)