Class: R2do::App
- Inherits:
-
Object
- Object
- R2do::App
- Defined in:
- lib/r2do.rb
Constant Summary
Constants included from R2do
Instance Method Summary collapse
-
#initialize(args) ⇒ App
constructor
Creates an instance of the application.
-
#run ⇒ void
Evaluates the command passed by the user and calls the corresponding application command.
-
#save ⇒ void
Saves the state of the application.
Methods included from Utility
calculate_path, load_state, save_state, show_help, show_version
Constructor Details
#initialize(args) ⇒ App
Creates an instance of the application.
45 46 47 48 49 50 51 52 |
# File 'lib/r2do.rb', line 45 def initialize(args) @args = args @file_name = ".r2do.yml" @state = load_state(@file_name) @commands = create_commands() end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Evaluates the command passed by the user and calls the corresponding application command.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/r2do.rb', line 57 def run() option = @args[0] if @args.length > 0 cmd = find_command(option) if not cmd.nil? begin cmd.execute(@args) rescue Exception => e UI.rescue(e) end else invalid_command(option) end else show_help(@args) end end |
#save ⇒ void
This method returns an undefined value.
Saves the state of the application
79 80 81 82 83 |
# File 'lib/r2do.rb', line 79 def save() if @state.modified save_state(@file_name, @state) end end |