Class: Menu::TimeMenu::MonthtimeMenu
- Inherits:
-
IntervaltimeMenu
- Object
- Base
- TimeMenu
- IntervaltimeMenu
- Menu::TimeMenu::MonthtimeMenu
- Defined in:
- lib/menu/worktime/monthtime_menu.rb
Overview
menu class to present the available query options for a given month and for a given entity, identified by its id
Instance Attribute Summary
Attributes inherited from TimeMenu
#additions, #time_string, #values
Attributes inherited from Base
#menu_description, #menu_items
Instance Method Summary collapse
-
#calculate_month_and_next_month(year, month) ⇒ Hash
private
method to calculate the time boundaries for the given month.
-
#initialize ⇒ MonthtimeMenu
constructor
initialization.
-
#retrieve_tasks ⇒ Hash
private
method to retrieve all task that started, ended or took place within the given month for the provided id.
-
#retrieve_worktime ⇒ Hash
private
method to retrieve the overall worktime for an entity with the given id for the given month.
-
#set_boundaries ⇒ Object
private
method to calculate the date boundaries of the provided user input.
Methods inherited from IntervaltimeMenu
#get_input_values, #set_values
Methods inherited from TimeMenu
#calculate_worktime, #check_attributes, #check_time_string, #define_menu_items, #determine_action, #get_input_values, #output_to_csv, #print_all_tasks, #print_tasks_in_interval, #print_tasks_to_key, #retrieve_and_print_worktime
Methods inherited from Base
#add_menu_item, #define_menu_items, #determine_action, #get_entry, #handle_wrong_option, #print_menu
Constructor Details
#initialize ⇒ MonthtimeMenu
initialization
12 13 14 |
# File 'lib/menu/worktime/monthtime_menu.rb', line 12 def initialize super("month") end |
Instance Method Details
#calculate_month_and_next_month(year, month) ⇒ Hash (private)
method to calculate the time boundaries for the given month
47 48 49 50 |
# File 'lib/menu/worktime/monthtime_menu.rb', line 47 def calculate_month_and_next_month(year, month) check_date = Time.new(year, month) {:actual => check_date, :next => check_date.next_month} end |
#retrieve_tasks ⇒ Hash (private)
method to retrieve all task that started, ended or took place within the given month for the provided id
22 23 24 |
# File 'lib/menu/worktime/monthtime_menu.rb', line 22 def retrieve_tasks Query.get_data(@values[:id], @values[:start_time], @values[:end_time]) end |
#retrieve_worktime ⇒ Hash (private)
method to retrieve the overall worktime for an entity with the given id for the given month
29 30 31 32 |
# File 'lib/menu/worktime/monthtime_menu.rb', line 29 def retrieve_worktime Query.get_monthly_worktime(@values[:id], @values[:start_time], @values[:end_time]) end |
#set_boundaries ⇒ Object (private)
method to calculate the date boundaries of the provided user input
35 36 37 38 39 40 41 |
# File 'lib/menu/worktime/monthtime_menu.rb', line 35 def set_boundaries months = calculate_month_and_next_month(@values[:year], @values[:time_frame]) set_values(months) return "Calculated interval for month from input:" \ " #{months[:actual]} - #{months[:next]}" end |