class CollectionManager

Collection Manager Class to manage collections

Public Class Methods

new() click to toggle source
# File lib/collection_manager.rb, line 8
def initialize
  @current_id = 0;
  @collections = Hash.new
end

Public Instance Methods

add(collection) click to toggle source

Adds a new collection to the Hash object

Example:

>> cm = CollectionManager.new
>> cm.add(Stack.new)

Arguments:

a collection object, eg. Stack or Queue
# File lib/collection_manager.rb, line 23
def add(collection)
  @current_id += 1
  @collections[@current_id] = collection
end
all() click to toggle source

Returns all the collections

# File lib/collection_manager.rb, line 56
def all
  @collections
end
delete(id) click to toggle source

Deletes a collection from the Hash object

Example:

>> cm.delete(1)

Arguments:

id of the collection
# File lib/collection_manager.rb, line 37
def delete(id)
  @collections.delete(id)
end
find(id) click to toggle source

Returns a collection form the Hash id with key as id

Example:

>> cm.find(1)
=> value at key 1 in the Hash object

Arguments:

id of the collection
# File lib/collection_manager.rb, line 50
def find(id)
  @collections[id]
end