Class: Conglomerate::Array

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/conglomerate/array.rb

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Array

Returns a new instance of Array.



5
6
7
8
# File 'lib/conglomerate/array.rb', line 5

def initialize(type)
  self.type = type
  self.storage = []
end

Instance Method Details

#<<(val) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/conglomerate/array.rb', line 10

def <<(val)
  if type
    raise "TypeMismatch" unless val.is_a?(type)
  end

  storage << val
end

#each(&block) ⇒ Object



22
23
24
# File 'lib/conglomerate/array.rb', line 22

def each(&block)
  storage.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/conglomerate/array.rb', line 18

def empty?
  storage.empty?
end