Class: KXI::Collections::HashCollection
- Inherits:
-
Enumerable
- Object
- Enumerable
- KXI::Collections::HashCollection
- Defined in:
- lib/kxi/collections/hash_collection.rb
Overview
Makes hash enumerable. Every key-value pair of hash is represented by HashEnumerator::KeyValuePair class
Defined Under Namespace
Classes: HashEnumerator
Instance Method Summary collapse
-
#[](key) ⇒ Object
Gets value from hash at given key.
-
#[]=(key, value) ⇒ Object
Sets value to hash at given key.
-
#initialize(hash) ⇒ HashCollection
constructor
Instantiates the HashCollection class.
Methods inherited from Enumerable
#aggregate, #all, #any, #can_alter?, #count, #enumerator, #first, #first!, #foreach, #last, #last!, #max, #min, #of_type, #of_type!, #order_by, #order_by_descending, #select, #select_many, #skip, #take, #to_array, #where
Constructor Details
#initialize(hash) ⇒ HashCollection
Instantiates the KXI::Collections::HashCollection class
10 11 12 13 |
# File 'lib/kxi/collections/hash_collection.rb', line 10 def initialize(hash) super() @hash = hash end |
Instance Method Details
#[](key) ⇒ Object
Gets value from hash at given key
24 25 26 27 28 |
# File 'lib/kxi/collections/hash_collection.rb', line 24 def [](key) lock do return @hash[key] end end |
#[]=(key, value) ⇒ Object
Sets value to hash at given key
34 35 36 37 38 39 |
# File 'lib/kxi/collections/hash_collection.rb', line 34 def []=(key, value) lock(true) do @hash[key] = value end return value end |