Sha256: 0e3c290b0ceb3688fe39dcb7a7cd69a3a3112ee48b705d393db5465d2fafb42b

Contents?: true

Size: 905 Bytes

Versions: 22

Compression:

Stored size: 905 Bytes

Contents

module Picky

  #
  #
  class Category

    attr_reader :indexed_exact,
                :indexed_partial

    # Loads the index from cache.
    #
    def load_from_cache
      timed_exclaim %Q{"#{identifier}": Loading index from cache.}
      indexed_exact.load
      indexed_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? ? indexed_partial : indexed_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

22 entries across 22 versions & 1 rubygems

Version Path
picky-3.0.0.pre2 lib/picky/category_indexed.rb
picky-3.0.0.pre1 lib/picky/category_indexed.rb