Class: View
- Inherits:
-
SimpleConsole::View
- Object
- SimpleConsole::View
- View
- Defined in:
- lib/task.rb
Overview
:nodoc:
Instance Method Summary collapse
- #default ⇒ Object
- #help ⇒ Object
- #info ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
- #time_format ⇒ Object
Instance Method Details
#default ⇒ Object
153 154 155 156 157 |
# File 'lib/task.rb', line 153 def default @list.each do |name, task, elapsed, last_elapsed| puts "- #{time_format % elapsed} / #{time_format % last_elapsed} for task #{name.cyan}#{" (running)" if task[:running]}" end end |
#help ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/task.rb', line 184 def help puts <<-eos Usage: task [action] [name] [options] Actions: default Lists all tasks with their respective status and elapsed time. start Starts the time tracking for the selected task. stop Stops the time tracking for the selected task. info Shows elapsed time for the selected task. reset Reverts the status to the last saved elapsed time (ignores the latest start command). delete Deletes the selected task. add Modifies the elapsed time for some task. Options for this are required. Options: -s --seconds Useful only for the add command. Adds -s seconds to the time elapsed. -m --minutes Useful only for the add command. Adds -m minutes to the time elapsed. -h --hours Useful only for the add command. Adds -h hours to the time elapsed. Examples: task start d21 Starts the time tracking for task d21. task stop d21 Stops the time tracking for task d21. task start Starts the time tracking for task default. task add -h 1 Adds one hour to the elapsed time of task default. task add -m -10 Substracts ten minutes from the elapsed time of task default. task add d21 -m 20 -s 30 Adds twenty minutes and thirty seconds to the task d21. task info d21 Shows elapsed time for task d21. eos end |
#info ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'lib/task.rb', line 171 def info puts "- Time elapsed for task #{@task.cyan}" puts " This session: #{time_format % [@hours, @minutes, @seconds]}" unless @elapsed.zero? @daily.each do |date, elapsed| puts " * #{date}: #{time_format % elapsed}" end end |
#start ⇒ Object
159 160 161 |
# File 'lib/task.rb', line 159 def start status end |
#status ⇒ Object
167 168 169 |
# File 'lib/task.rb', line 167 def status puts "- Task #{@task.cyan} for user #{@user.cyan} #{params[:action]}s at #{@time.strftime("%B %d, %Y %H:%M")}" end |
#stop ⇒ Object
163 164 165 |
# File 'lib/task.rb', line 163 def stop status end |
#time_format ⇒ Object
180 181 182 |
# File 'lib/task.rb', line 180 def time_format "%02d:%02d:%02d".yellow end |