Class: SortedHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/sorted_hash.rb

Instance Method Summary collapse

Constructor Details

#initializeSortedHash

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

#eachObject



14
15
16
# File 'lib/sorted_hash.rb', line 14

def each
  @keys.each { |key| yield [key, self[key]] }
end