Class: HandyToolbox::App
- Inherits:
-
Object
- Object
- HandyToolbox::App
- Defined in:
- lib/handy_toolbox/app.rb
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title: "Tools", default_colors: false) ⇒ App
constructor
A new instance of App.
- #menu(group, &block) ⇒ Object
- #menu_loader(group, loader_class) ⇒ Object
- #plugin(plugin_class) ⇒ Object
- #run ⇒ Object
- #tool(cmd, opts = {}) ⇒ Object
Constructor Details
#initialize(title: "Tools", default_colors: false) ⇒ App
Returns a new instance of App.
6 7 8 9 10 11 12 13 14 |
# File 'lib/handy_toolbox/app.rb', line 6 def initialize(title: "Tools", default_colors: false) @title = title @loop = true @builder = Menu.new(nil, nil) @screen = Screen.new(default_colors: default_colors) @navigator = Navigator.new @tool_runner = ToolRunner.new @positions = {} end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/handy_toolbox/app.rb', line 4 def title @title end |
Instance Method Details
#menu(group, &block) ⇒ Object
40 41 42 |
# File 'lib/handy_toolbox/app.rb', line 40 def (group, &block) builder.(group, &block) end |
#menu_loader(group, loader_class) ⇒ Object
44 45 46 |
# File 'lib/handy_toolbox/app.rb', line 44 def (group, loader_class) builder.(group, loader_class) end |
#plugin(plugin_class) ⇒ Object
36 37 38 |
# File 'lib/handy_toolbox/app.rb', line 36 def plugin(plugin_class) builder.plugin(plugin_class) end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/handy_toolbox/app.rb', line 16 def run screen.init navigator.enter(builder) begin while @loop screen.draw do screen.header(title) draw_tools end handle_input end ensure screen.close tool_runner.run end end |
#tool(cmd, opts = {}) ⇒ Object
48 49 50 |
# File 'lib/handy_toolbox/app.rb', line 48 def tool(cmd, opts = {}) builder.tool(cmd, opts) end |