Class: SortedHash
- Inherits:
-
Hash
- Object
- Hash
- SortedHash
- Defined in:
- lib/sorted_hash.rb
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ SortedHash
constructor
A new instance of SortedHash.
Constructor Details
#initialize ⇒ SortedHash
Returns a new instance of SortedHash.
4 5 6 7 |
# File 'lib/sorted_hash.rb', line 4 def initialize super @keys = SortedSet.new end |
Instance Method Details
#[]=(key, value) ⇒ Object
9 10 11 12 |
# File 'lib/sorted_hash.rb', line 9 def []=(key, value) @keys.add(key) super end |
#each ⇒ Object
14 15 16 |
# File 'lib/sorted_hash.rb', line 14 def each @keys.each { |key| yield [key, self[key]] } end |