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.
9 10 11 12 |
# File 'lib/menu_commander/menu.rb', line 9 def initialize(config) config = YAML.ext_load_file config if config.is_a? String @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/menu_commander/menu.rb', line 7 def config @config end |
Instance Method Details
#call(menu = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/menu_commander/menu.rb', line 14 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 => e puts "\n\n" call e. end |
#options ⇒ Object
28 29 30 |
# File 'lib/menu_commander/menu.rb', line 28 def ||= MenuOptions.new(config['options']) end |