Class: Mittsu::HashArray

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mittsu/core/hash_array.rb

Instance Method Summary collapse

Constructor Details

#initializeHashArray

Returns a new instance of HashArray.



5
6
7
8
# File 'lib/mittsu/core/hash_array.rb', line 5

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

Instance Method Details

#[](key) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/mittsu/core/hash_array.rb', line 10

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

#[]=(key, value) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/mittsu/core/hash_array.rb', line 18

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

#each(&block) ⇒ Object



26
27
28
# File 'lib/mittsu/core/hash_array.rb', line 26

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

#lengthObject Also known as: count, size



30
31
32
# File 'lib/mittsu/core/hash_array.rb', line 30

def length
  @array.length
end