Sha256: a6a81863105aaa66fd46f28021b41c9643e0325376e471b1cbd7bcfee74af53b

Contents?: true

Size: 524 Bytes

Versions: 5

Compression:

Stored size: 524 Bytes

Contents

module Lunar
  # @private Used internally by Lunar::search to get all the fuzzy matches
  # given `nest`, `att` and it's `val`.
  class FuzzyMatches
    attr :nest
    attr :att
    attr :value

    def initialize(nest, att, value)
      @nest, @att, @value = nest, att.to_sym, value
    end

    def distkey
      nest[{ att => value }.hash].tap do |dk|
        dk.zunionstore keys.flatten
      end
    end

  protected
    def keys
      Words.new(value).map { |w| nest[:Fuzzies][att][Lunar.encode(w)] }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lunar-0.5.4 lib/lunar/fuzzy_matches.rb
lunar-0.5.3 lib/lunar/fuzzy_matches.rb
lunar-0.5.2 lib/lunar/fuzzy_matches.rb
lunar-0.5.1 lib/lunar/fuzzy_matches.rb
lunar-0.5.0 lib/lunar/fuzzy_matches.rb