Class: CmdExecute

Inherits:
CmdBase show all
Defined in:
lib/shell.rb

Overview

Command execute

Constant Summary collapse

NAME =
'execute'
ALIASES =
['e'].freeze
ARGUMENTS =
['num'].freeze
DESCRIPTION =
'Execute the level'

Instance Method Summary collapse

Methods inherited from CmdBase

#aliases, #arguments, #description, #initialize, #name

Constructor Details

This class inherits a constructor from CmdBase

Instance Method Details

#exec(args) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/shell.rb', line 165

def exec(args)
  unless args[0].nil?
    level = args[0].to_i
    if level >= 0 && level <= @shell.natas.class::MAXLEVEL
      @shell.natas.level = level
    else
      puts @shell.console.red("Level must be between 0-#{@shell.natas.class::MAXLEVEL}")
      return
    end
  end

  @shell.natas.level = 0 if @shell.natas.level.nil?

  begin
    @shell.natas.exec
  rescue StandardError => e
    puts @shell.console.red(e)
  end
end