Class: Coals::Menu

Inherits:
Object
  • Object
show all
Defined in:
lib/coals/menu.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options:, prompt: nil, title: '') ⇒ Menu

Show a menu of options in a loop until the user makes a selection. Return the selection value

Parameters:

  • menu (Array)
    • list of options to choose from



10
11
12
13
14
15
16
# File 'lib/coals/menu.rb', line 10

def initialize(options:, prompt: nil, title: '')
  @select = nil
  @options = options
  @title = title
  @prompt = prompt
  show_menu until @selection
end

Instance Attribute Details

#selectionObject (readonly)

Returns the value of attribute selection.



4
5
6
# File 'lib/coals/menu.rb', line 4

def selection
  @selection
end