Class: MenuCommander::Menu
- Inherits:
-
Object
- Object
- MenuCommander::Menu
- Defined in:
- lib/menu_commander/menu.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #call(menu = nil) ⇒ Object
-
#initialize(config) ⇒ Menu
constructor
A new instance of Menu.
- #options ⇒ Object
Constructor Details
#initialize(config) ⇒ Menu
Returns a new instance of Menu.
8 9 10 11 |
# File 'lib/menu_commander/menu.rb', line 8 def initialize(config) config = ExtendedYAML.load config if config.is_a? String @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/menu_commander/menu.rb', line 6 def config @config end |
Instance Method Details
#call(menu = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/menu_commander/menu.rb', line 13 def call( = nil) ||= config['menu'] response = select response = combine_commands response if response.is_a? Array history << response.is_a?(String) ? evaluate(response) : call(response) rescue MenuNavigation => e puts "\n\n" call e. end |
#options ⇒ Object
26 27 28 |
# File 'lib/menu_commander/menu.rb', line 26 def @options ||= MenuOptions.new(config['options']) end |