Sha256: 3e186264f188d0846109459f8be64048b0cdefd889fd75c08a6dd19da8d909e9
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
#encoding: utf-8 # the main module module TheArrayComparator #caching class class Cache # 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
the_array_comparator-0.2.0 | lib/the_array_comparator/cache.rb |