Class: MenuCommander::MenuOptions
- Inherits:
-
Object
- Object
- MenuCommander::MenuOptions
show all
- Defined in:
- lib/menu_commander/menu_options.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ MenuOptions
5
6
7
8
9
|
# File 'lib/menu_commander/menu_options.rb', line 5
def initialize(options)
options ||= {}
options.transform_keys! &:to_sym
@options = default_options.merge options
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args, &_block) ⇒ Object
25
26
27
|
# File 'lib/menu_commander/menu_options.rb', line 25
def method_missing(method, *_args, &_block)
respond_to?(method) ? options[method] : super
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
3
4
5
|
# File 'lib/menu_commander/menu_options.rb', line 3
def options
@options
end
|
Instance Method Details
#default_options ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/menu_commander/menu_options.rb', line 11
def default_options
@default_options ||= {
auto_select: true,
echo: false,
echo_marker: '✓',
filter: 'auto',
header: false,
page_size: 10,
select_marker: "⯈",
submenu_marker: " ⯆",
title_marker: "▌",
}
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
29
30
31
|
# File 'lib/menu_commander/menu_options.rb', line 29
def respond_to_missing?(method_name, include_private=false)
options.has_key?(method_name) || super
end
|