Sha256: 7c8de07c336ecd4241639103c8268fcf4187f440dbaf3a2af7906c14ceb4d036

Contents?: true

Size: 807 Bytes

Versions: 8

Compression:

Stored size: 807 Bytes

Contents

module Picky

  #
  #
  class Category

    # Loads the index from cache.
    #
    def load_from_cache
      timed_exclaim %Q{"#{identifier}": Loading index from cache.}
      exact.load
      partial.load
    end
    alias reload load_from_cache

    # Gets the weight for this token's text.
    #
    def weight token
      bundle_for(token).weight token.text
    end

    # Gets the ids for this token's text.
    #
    def ids token
      bundle_for(token).ids token.text
    end

    # Returns the right index bundle for this token.
    #
    def bundle_for token
      token.partial? ? partial : exact
    end

    # Returns a combination for the token,
    # or nil, if there is none.
    #
    def combination_for token
      weight(token) && Query::Combination.new(token, self)
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
picky-3.4.3 lib/picky/category_indexed.rb
picky-3.4.2 lib/picky/category_indexed.rb
picky-3.4.1 lib/picky/category_indexed.rb
picky-3.4.0 lib/picky/category_indexed.rb
picky-3.3.3 lib/picky/category_indexed.rb
picky-3.3.2 lib/picky/category_indexed.rb
picky-3.3.1 lib/picky/category_indexed.rb
picky-3.3.0 lib/picky/category_indexed.rb