Sha256: df44c00697d3a757714ed6b148336909907bc10ec06011f61a52a9cd7c364d92
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 KB
Contents
#encoding: utf-8 # the main module module TheArrayComparator #caching strategies module CachingStrategies #anonymous cache class AnonymousCache # Create cache def initialize @cache = [] @new_objects = false end # Add object to cache # # @param [Object] obj # the object which should be added to the cache # # @return [Object] # the object which has beed added def add(obj) @cache << obj @new_objects = true obj end # Return all stored objects # # @return [Array] # the cache def stored_objects @new_objects = false @cache end # Clear the cache (delete all objects) def clear @cache = [] end # Are there new objects # # @return [TrueClass,FalseClass] # the result of the check def new_objects? @new_objects end # Delete an object from cache by number # # @return # the deleted object def delete_object(num) @cache.delete_at(num) end # Request an object from cache by number # # @return # the requested object def fetch_object(num) @cache[num] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems