Class: Menu::IndexSelectionMenu

Inherits:
Base
  • Object
show all
Includes:
Listenable
Defined in:
lib/menu/index_menus/index_selection_menu.rb

Overview

menu class that inherits Base to abstract the menu to select a given status

Instance Attribute Summary

Attributes inherited from Base

#menu_description, #menu_items

Instance Method Summary collapse

Methods included from Listenable

#add_listener, #listeners, #notify_listeners, #remove_listener

Methods inherited from Base

#add_menu_item, #get_entry, #handle_wrong_option, #print_menu

Constructor Details

#initializeIndexSelectionMenu

initialization



9
10
11
12
# File 'lib/menu/index_menus/index_selection_menu.rb', line 9

def initialize
  @menu_description = "Index overview. Select the criteria for the index:"
  super
end

Instance Method Details

#define_menu_itemsObject (private)

implementation to define the items of the menu



17
18
19
20
21
22
# File 'lib/menu/index_menus/index_selection_menu.rb', line 17

def define_menu_items
  add_menu_item("Http request", 1)
  add_menu_item("Http status", 2)
  add_menu_item("Sourceadress", 3)
  add_menu_item("Timestamp", 4)
end

#determine_action(input) ⇒ Object (private)

method to specify the actions to a given input

Parameters:

  • input (String)

    the user input



26
27
28
29
30
31
32
33
34
35
# File 'lib/menu/index_menus/index_selection_menu.rb', line 26

def determine_action(input)
  case (input.to_i)
    when 1 then notify_listeners(:change_index, :http_request)
    when 2 then notify_listeners(:change_index, :http_status)
    when 3 then notify_listeners(:change_index, :source)
    when 4 then notify_listeners(:change_index, :timestamp)
  else
    handle_wrong_option
  end
end