Sha256: 3e95894cb34352d0876437023ad68c8e852525a797a7947be5c219618d469f33

Contents?: true

Size: 630 Bytes

Versions: 3

Compression:

Stored size: 630 Bytes

Contents

# coding: utf-8

module ThinReports
  module Core
    
    ruby_18 do
      # @private
      class OrderedHash < ::Hash
        def initialize
          @keys = []
          super
        end
        
        def []=(key, value)
          @keys << key unless member?(key)
          super
        end
        
        def each
          @keys.each {|key| yield(key, self[key])}
        end
        
        def each_key
          @keys.each {|key| yield(key)}
        end
        
        def keys
          @keys
        end
      end
    end
    
    ruby_19 do
      # @private
      OrderedHash = ::Hash
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.7.7 lib/thinreports/core/ordered_hash.rb
thinreports-0.7.6 lib/thinreports/core/ordered_hash.rb
thinreports-0.7.5 lib/thinreports/core/ordered_hash.rb