Class: TaskLogger
- Inherits:
-
Object
- Object
- TaskLogger
- Defined in:
- lib/task_logger.rb
Constant Summary collapse
- TIME_FORMAT =
"%Y-%m-%d %H:%M"
Instance Method Summary collapse
-
#initialize(tasks_path) ⇒ TaskLogger
constructor
A new instance of TaskLogger.
- #list ⇒ Object
- #resume ⇒ Object
- #start(task_description) ⇒ Object
Constructor Details
#initialize(tasks_path) ⇒ TaskLogger
Returns a new instance of TaskLogger.
7 8 9 |
# File 'lib/task_logger.rb', line 7 def initialize(tasks_path) @tasks_path = tasks_path end |
Instance Method Details
#list ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/task_logger.rb', line 39 def list exit_if_missing_data tasks[-5, 5].each do |task| puts task.to_csv end end |
#resume ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/task_logger.rb', line 22 def resume exit_if_missing_data last_task_data = tasks.pop last_task = Task.from_array(last_task_data) last_task.finish! penultimate_task_data = tasks.last penultimate_task = Task.from_array(penultimate_task_data) penultimate_task.restart! tasks << last_task.to_a tasks << penultimate_task.to_a write_tasks end |
#start(task_description) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/task_logger.rb', line 11 def start(task_description) task = Task.new(task_description) if last_task_data = tasks.pop last_task = Task.from_array(last_task_data) last_task.finish! tasks << last_task.to_a end tasks << task.to_a write_tasks end |