class KXI::Collections::HashCollection

Makes hash enumerable. Every key-value pair of hash is represented by {KXI::Collections::HashCollection::HashEnumerator::KeyValuePair} class

Public Class Methods

new(hash) click to toggle source

Instantiates the {KXI::Collections::HashCollection} class @param hash [Hash] Hash for enumeration

Calls superclass method KXI::Collections::Enumerable::new
# File lib/kxi/collections/hash_collection.rb, line 10
def initialize(hash)
        super()
        @hash = hash
end

Public Instance Methods

[](key) click to toggle source

Gets value from hash at given key @param key [Object] Key of value to obtain @return [Object] Obtained value

# File lib/kxi/collections/hash_collection.rb, line 24
def [](key)
        lock do
                return @hash[key]
        end
end
[]=(key, value) click to toggle source

Sets value to hash at given key @param key [Object] Key of pair to set @param value [Object] Value to set the pair to @return [Object] Given value

# File lib/kxi/collections/hash_collection.rb, line 34
def []=(key, value)
        lock(true) do
                @hash[key] = value
        end
        return value
end

Protected Instance Methods

create_enumerator() click to toggle source

Creates a new {KXI::Collections::Enumerator} bound to this instance @return [KXI::Collections::Enumerator] Enumerator bound to this instance

# File lib/kxi/collections/hash_collection.rb, line 17
def create_enumerator
        HashEnumerator.new(@hash)
end