Method: Shell#initialize

Defined in:
lib/shell.rb

#initializeShell

Returns a new instance of Shell.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/shell.rb', line 20

def initialize
  @console = Console.new
  @natas = Natas.new(self)
  @commands = []
  ObjectSpace.each_object(Class).select { |c| c < CmdBase }.each { |c| @commands << c.new(self) }
  @commands.sort! { |a, b| a.name <=> b.name }

  return unless File.exist?(CONFIG_FILE)

  config = YAML.safe_load(File.read(CONFIG_FILE))
  @natas.levels.each do |level|
    level.password = config.fetch(level.level, nil)
  end
end