Sha256: 42fa14b8cfdc945443188f2b29870161edab58680fcf91a37cdebae9d6e05964

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

# encoding: utf-8
#
module Indexed # :nodoc:all

  #
  #
  module Bundle

    # This is the _actual_ index (based on memory).
    #
    # Handles exact/partial index, weights index, and similarity index.
    #
    # Delegates file handling and checking to an *Indexed*::*Files* object.
    #
    class Memory < Base

      delegate :[], :to => :configuration

      def initialize name, configuration, *args
        super name, configuration, *args

        @configuration = {} # A hash with config options.

        @backend = Backend::Files.new name, configuration
      end

      # Get the ids for the given symbol.
      #
      def ids sym
        @inverted[sym] || []
      end
      # Get a weight for the given symbol.
      #
      def weight sym
        @weights[sym]
      end

      # Loads the core index.
      #
      def load_inverted
        self.inverted = @backend.load_inverted
      end
      # Loads the weights index.
      #
      def load_weights
        self.weights = @backend.load_weights
      end
      # Loads the similarity index.
      #
      def load_similarity
        self.similarity = @backend.load_similarity
      end
      # Loads the configuration.
      #
      def load_configuration
        self.configuration = @backend.load_configuration
      end

      # Loads the core index.
      #
      def clear_inverted
        self.inverted = {}
      end
      # Loads the weights index.
      #
      def clear_weights
        self.weights = {}
      end
      # Loads the similarity index.
      #
      def clear_similarity
        self.similarity = {}
      end
      # Loads the configuration.
      #
      def clear_configuration
        self.configuration = {}
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-2.7.0 lib/picky/indexed/bundle/memory.rb