Class: Menu::WorktimeQueries

Inherits:
Base
  • Object
show all
Defined in:
lib/menu/worktime/worktime_queries.rb

Overview

menu class to process the queries of different worktime intervals

Instance Attribute Summary

Attributes inherited from Base

#menu_description, #menu_items

Instance Method Summary collapse

Methods inherited from Base

#add_menu_item, #get_entry, #handle_wrong_option, #print_menu

Constructor Details

#initializeWorktimeQueries

initialization



9
10
11
12
# File 'lib/menu/worktime/worktime_queries.rb', line 9

def initialize
  super
  @menu_description = "Queries for tasks done in a given time interval."
end

Instance Method Details

#define_menu_itemsObject (private)

method to define all printable menu items



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

def define_menu_items
  add_menu_item("Weekly worktime.", 1)
  add_menu_item("Monthly worktime.", 2)
  add_menu_item("Custom worktime interval.", 3)
  add_menu_item("Cancel and return to previous menu.", 4)
end

#determine_action(input) ⇒ Boolean (private)

method to process the provided input

Parameters:

  • input (String)

    the provided input

Returns:

  • (Boolean)

    true: if the program should continue, false: if the script should return to the previous menu



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/menu/worktime/worktime_queries.rb', line 28

def determine_action(input)
  case (input.to_i)
    when 1 then TimeMenu::WeektimeMenu.new.print_menu
    when 2 then TimeMenu::MonthtimeMenu.new.print_menu
    when 3 then TimeMenu::CustomtimeMenu.new.print_menu
    when 4 then return false
  else
    handle_wrong_option
  end
  return true
end