Sha256: 3ac6c1d00bd52aa871bf1e7fdeffba31119cbb1d78004cae0d54c78a90b5893c
Contents?: true
Size: 1.28 KB
Versions: 5
Compression:
Stored size: 1.28 KB
Contents
#encoding: utf-8 # the main module module TheArrayComparator #caching strategies module CachingStrategies #anonymous cache class SingleValueCache # 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 @cache.delete_at(0) end # Request an object from cache by number # # @return # the requested object def fetch_object @cache[0] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems