Sha256: 26b0e9791445a7944bf2307f9f23e547cd34376c1c2d88ab15b40033228617aa

Contents?: true

Size: 1.83 KB

Versions: 7

Compression:

Stored size: 1.83 KB

Contents

# encoding: utf-8
#
module Picky

  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, category, *args
          super name, category, *args

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

          @backend = Backend::Files.new self
        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

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
picky-3.0.1 lib/picky/indexed/bundle/memory.rb
picky-3.0.0 lib/picky/indexed/bundle/memory.rb
picky-3.0.0.pre5 lib/picky/indexed/bundle/memory.rb
picky-3.0.0.pre4 lib/picky/indexed/bundle/memory.rb
picky-3.0.0.pre3 lib/picky/indexed/bundle/memory.rb
picky-3.0.0.pre2 lib/picky/indexed/bundle/memory.rb
picky-3.0.0.pre1 lib/picky/indexed/bundle/memory.rb