Class: ZombieList

Inherits:
Object
  • Object
show all
Defined in:
lib/zombie-chaser/human.rb

Direct Known Subclasses

MockZombieList

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zombie_factory) ⇒ ZombieList

Returns a new instance of ZombieList.



208
209
210
211
# File 'lib/zombie-chaser/human.rb', line 208

def initialize(zombie_factory)
  @zombie_factory = zombie_factory
  @zombies = []
end

Class Method Details

.new_using_test_unit_handler(test_pattern, world) ⇒ Object



203
204
205
206
# File 'lib/zombie-chaser/human.rb', line 203

def self.new_using_test_unit_handler(test_pattern, world)
  zombie_factory = ZombieFactory.new(test_pattern, world)
  new(zombie_factory)
end

Instance Method Details

#draw_zombiesObject



223
224
225
# File 'lib/zombie-chaser/human.rb', line 223

def draw_zombies
  each_zombie {|zombie| zombie.draw}
end

#each_zombieObject



219
220
221
# File 'lib/zombie-chaser/human.rb', line 219

def each_zombie
  @zombies.each{|zombie| yield zombie}
end

#supply_next_zombieObject



213
214
215
216
217
# File 'lib/zombie-chaser/human.rb', line 213

def supply_next_zombie
  zombie = @zombie_factory.create_zombie
  @zombies << zombie
  zombie
end