Sha256: fa2596b2e6fb8aa1eba8d526135bf1aed24106ddb5b79ee9c2a3eaf440e3ffd6

Contents?: true

Size: 541 Bytes

Versions: 11

Compression:

Stored size: 541 Bytes

Contents

module Mittsu
  class HashArray
    include Enumerable

    def initialize()
      @array = []
      @hash = {}
    end

    def [](key)
      if key.is_a? Fixnum
        @array[key]
      else
        @hash[key]
      end
    end

    def []=(key, value)
      if key.is_a? Fixnum
        @array[key] = value
      else
        @hash[key] = value
      end
    end

    def each(&block)
      @array.each(&block)
    end

    def length
      @array.length
    end
    alias_method :count, :length
    alias_method :size, :length
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mittsu-0.2.2 lib/mittsu/core/hash_array.rb
mittsu-0.2.1 lib/mittsu/core/hash_array.rb
mittsu-0.2.0 lib/mittsu/core/hash_array.rb
mittsu-0.1.7 lib/mittsu/core/hash_array.rb
mittsu-0.1.6 lib/mittsu/core/hash_array.rb
mittsu-0.1.5 lib/mittsu/core/hash_array.rb
mittsu-0.1.4 lib/mittsu/core/hash_array.rb
mittsu-0.1.3 lib/mittsu/core/hash_array.rb
mittsu-0.1.2 lib/mittsu/core/hash_array.rb
mittsu-0.1.1 lib/mittsu/core/hash_array.rb
mittsu-0.1.0 lib/mittsu/core/hash_array.rb