Sha256: 8af5bbba8d827333bae93a3932f1ae01fff7213c9e8b76fe96029d9410b0ed58

Contents?: true

Size: 1.94 KB

Versions: 19

Compression:

Stored size: 1.94 KB

Contents

module Internals

  # 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 = Internals::Index::Files.new name, configuration
        end

        def to_s
          <<-MEMORY
Memory
#{@backend.indented_to_s}
MEMORY
        end

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

        # Loads the core index.
        #
        def load_index
          self.index = @backend.load_index
        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_index
          self.index = {}
        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

19 entries across 19 versions & 1 rubygems

Version Path
picky-2.5.2 lib/picky/internals/indexed/bundle/memory.rb
picky-2.5.1 lib/picky/internals/indexed/bundle/memory.rb
picky-2.5.0 lib/picky/internals/indexed/bundle/memory.rb
picky-2.4.3 lib/picky/internals/indexed/bundle/memory.rb
picky-2.4.2 lib/picky/internals/indexed/bundle/memory.rb
picky-2.4.1 lib/picky/internals/indexed/bundle/memory.rb
picky-2.4.0 lib/picky/internals/indexed/bundle/memory.rb
picky-2.3.0 lib/picky/internals/indexed/bundle/memory.rb
picky-2.2.1 lib/picky/internals/indexed/bundle/memory.rb
picky-2.2.0 lib/picky/internals/indexed/bundle/memory.rb
picky-2.1.2 lib/picky/internals/indexed/bundle/memory.rb
picky-2.1.1 lib/picky/internals/indexed/bundle/memory.rb
picky-2.1.0 lib/picky/internals/indexed/bundle/memory.rb
picky-2.0.0 lib/picky/internals/indexed/bundle/memory.rb
picky-2.0.0.pre3 lib/picky/internals/indexed/bundle/memory.rb
picky-2.0.0.pre2 lib/picky/internals/indexed/bundle/memory.rb
picky-2.0.0.pre1 lib/picky/internals/indexed/bundle/memory.rb
picky-1.5.4 lib/picky/internals/indexed/bundle/memory.rb
picky-1.5.3 lib/picky/internals/indexed/bundle/memory.rb