Class: RobotArmy::OfficerLoader

Inherits:
Loader show all
Defined in:
lib/robot-army/officer_loader.rb

Instance Attribute Summary

Attributes inherited from Loader

#messenger

Instance Method Summary collapse

Methods inherited from Loader

#libraries, #render, #safely, #safely_or_die

Instance Method Details

#loadObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/robot-army/officer_loader.rb', line 2

def load
  # create a soldier
  soldier = safely_or_die{ RobotArmy::Officer.new(messenger) }
  
  # use the soldier to start listening to incoming commands
  # at this point everything has been loaded successfully, so we
  # don't have to exit if an exception is thrown
  loop do
    safely{ soldier.listen }
  end
end