Sha256: b7dbc7d8a12e75a0559be9b865e4e26525cafcec3e64a0ecba7f7c74668adc8e

Contents?: true

Size: 543 Bytes

Versions: 9

Compression:

Stored size: 543 Bytes

Contents

module Mittsu
  class HashArray
    include Enumerable

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

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

    def []=(key, value)
      if key.is_a? Integer
        @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

9 entries across 9 versions & 1 rubygems

Version Path
mittsu-0.5.0 lib/mittsu/core/hash_array.rb
mittsu-0.4.1 lib/mittsu/core/hash_array.rb
mittsu-0.4.0 lib/mittsu/core/hash_array.rb
mittsu-0.3.3 lib/mittsu/core/hash_array.rb
mittsu-0.3.2 lib/mittsu/core/hash_array.rb
mittsu-0.3.1 lib/mittsu/core/hash_array.rb
mittsu-0.3.0 lib/mittsu/core/hash_array.rb
mittsu-0.2.4 lib/mittsu/core/hash_array.rb
mittsu-0.2.3 lib/mittsu/core/hash_array.rb