Class: MenuCommander::MenuOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/menu_commander/menu_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MenuOptions

Returns a new instance of 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



26
27
28
# File 'lib/menu_commander/menu_options.rb', line 26

def method_missing(method, *_args, &_block)
  respond_to?(method) ? options[method] : super
end

Instance Attribute Details

#optionsObject (readonly)

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_optionsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/menu_commander/menu_options.rb', line 11

def default_options
  @default_options ||= {
    auto_select:         true,
    echo:                false,
    echo_marker_success: '',
    echo_marker_error:   '',
    filter:              'auto',
    header:              false,
    page_size:           10,
    select_marker:       '',
    submenu_marker:      '',
    title_marker:        '', # ➤ ❚ ✚
  }
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/menu_commander/menu_options.rb', line 30

def respond_to_missing?(method_name, include_private = false)
  options.has_key?(method_name) || super
end