Class: Cmd
- Inherits:
-
Object
- Object
- Cmd
- Defined in:
- lib/Core.rb
Constant Summary collapse
- CLASS =
self
Instance Method Summary collapse
-
#initialize(prompt: "cmd> ", banner: "", msg: "") ⇒ Cmd
constructor
A new instance of Cmd.
- #loopcmd ⇒ Object
Constructor Details
#initialize(prompt: "cmd> ", banner: "", msg: "") ⇒ Cmd
Returns a new instance of Cmd.
3 4 5 6 7 |
# File 'lib/Core.rb', line 3 def initialize (prompt: "cmd> ", banner: "" , msg: "") @prompt = prompt @banner = @msg = msg end |
Instance Method Details
#loopcmd ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/Core.rb', line 8 def loopcmd Tools.print_filget @banner if @banner Tools.print_msg @msg unless @msg.empty? while true begin Tools.print @prompt command = gets.chomp if ["exit" , "quit"].include?(command) break elsif command.empty? nil elsif command.start_with?("help") handle_help(command) else handle_command(command) end rescue Interrupt break end end end |