Class: Controller
- Inherits:
-
SimpleConsole::Controller
- Object
- SimpleConsole::Controller
- Controller
- Defined in:
- lib/task.rb
Instance Method Summary collapse
-
#add ⇒ Object
Modifies the elapsed time for some task.
-
#default ⇒ Object
Lists all tasks with their respective status and elapsed time.
-
#delete ⇒ Object
Deletes the selected task.
-
#help ⇒ Object
Shows the usage reference and examples.
-
#info ⇒ Object
Shows elapsed time for the selected task.
-
#reset ⇒ Object
Reverts the status to the last saved elapsed time (ignores the latest start command).
-
#start ⇒ Object
Starts the time tracking for the selected task.
-
#stop ⇒ Object
Stops the time tracking for the selected task.
Instance Method Details
#add ⇒ Object
Modifies the elapsed time for some task. Options for this are required.
68 69 70 |
# File 'lib/task.rb', line 68 def add modify_elapsed time_join(params[:hours], params[:minutes], params[:seconds]) end |
#default ⇒ Object
Lists all tasks with their respective status and elapsed time.
26 27 28 29 30 31 |
# File 'lib/task.rb', line 26 def default redirect_to(:action => :help) if @tasks.empty? @list = @tasks.map do |name, task| [name, task, time_split(task[:elapsed]), time_split(last_elapsed(task))] end.sort end |
#delete ⇒ Object
Deletes the selected task.
63 64 65 |
# File 'lib/task.rb', line 63 def delete @tasks.delete(@task) end |
#help ⇒ Object
Shows the usage reference and examples.
73 74 |
# File 'lib/task.rb', line 73 def help end |
#info ⇒ Object
Shows elapsed time for the selected task.
34 35 36 37 38 39 40 |
# File 'lib/task.rb', line 34 def info @elapsed = last_elapsed @hours, @minutes, @seconds = time_split @elapsed @daily = task[:daily].sort.reverse.map do |day, elapsed| [day, time_split(elapsed)] end end |
#reset ⇒ Object
Reverts the status to the last saved elapsed time (ignores the latest start command).
57 58 59 60 |
# File 'lib/task.rb', line 57 def reset task[:started_at] = nil task[:running] = false end |
#start ⇒ Object
Starts the time tracking for the selected task.
43 44 45 46 47 |
# File 'lib/task.rb', line 43 def start redirect_to(:action => :info) if task[:running] task[:started_at] = @time task[:running] = true end |
#stop ⇒ Object
Stops the time tracking for the selected task.
50 51 52 53 54 |
# File 'lib/task.rb', line 50 def stop return unless task[:running] modify_elapsed(last_elapsed) reset end |