Sha256: 2b43672a33ff784129528c745d9f48e5954457a41f01fba675c86a5297e4f35b
Contents?: true
Size: 712 Bytes
Versions: 4
Compression:
Stored size: 712 Bytes
Contents
module Lunar # @private Used internally by Lunar::search to get all the word matches # given `nest`, `att` and it's `val`. class KeywordMatches attr :nest attr :att attr :value def initialize(nest, att, value) @nest, @att, @value = nest, att.to_sym, value end def distkey return if keys.flatten.empty? nest[{ att => value }.hash].tap do |dk| dk.zunionstore keys.flatten end end protected def keys if att == :q metaphones.map { |m| nest['*'][m].keys } else metaphones.map { |m| nest[att][m] } end end def metaphones Words.new(value).map { |word| Lunar.metaphone(word) } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lunar-0.5.5 | lib/lunar/keyword_matches.rb |
lunar-0.5.4 | lib/lunar/keyword_matches.rb |
lunar-0.5.3 | lib/lunar/keyword_matches.rb |
lunar-0.5.2 | lib/lunar/keyword_matches.rb |