Class: MakeMenu::Menu
- Inherits:
-
Object
- Object
- MakeMenu::Menu
- Defined in:
- lib/make_menu/menu.rb
Overview
This class builds and displays a number-selection menu from a Makefile then prompts for a number and executes the target.
Instance Attribute Summary collapse
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#status_present ⇒ Object
Returns the value of attribute status_present.
Instance Method Summary collapse
-
#display_header ⇒ Object
Display the company logo and the status bar (if set).
-
#initialize(makefile) ⇒ Menu
constructor
A new instance of Menu.
-
#run ⇒ Object
Display menu and prompt for command rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(makefile) ⇒ Menu
Returns a new instance of Menu.
12 13 14 15 16 17 |
# File 'lib/make_menu/menu.rb', line 12 def initialize(makefile) @groups = [] @items = [] @status_present = false build makefile end |
Instance Attribute Details
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
19 20 21 |
# File 'lib/make_menu/menu.rb', line 19 def groups @groups end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
19 20 21 |
# File 'lib/make_menu/menu.rb', line 19 def items @items end |
#status_present ⇒ Object
Returns the value of attribute status_present.
20 21 22 |
# File 'lib/make_menu/menu.rb', line 20 def status_present @status_present end |
Instance Method Details
#display_header ⇒ Object
Display the company logo and the status bar (if set)
49 50 51 52 |
# File 'lib/make_menu/menu.rb', line 49 def display_header puts formatted_logo if logo puts `make status` if status_present end |
#run ⇒ Object
Display menu and prompt for command rubocop:disable Metrics/MethodLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/make_menu/menu.rb', line 24 def run running = true while running system 'clear' if clear_screen? display_header puts colorize(TextTable.new(groups).to_s) puts puts 'Press ENTER to quit'.align(:center).bold puts print 'Select option: '.align(:center) running = false unless execute_option(gets.strip) end puts system 'clear' if clear_screen? end |