Class: Pomo::Task
- Inherits:
-
Object
- Object
- Pomo::Task
- Defined in:
- lib/pomo/task.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#complete ⇒ Object
Task completion bool.
-
#description ⇒ Object
Verbose task description.
-
#length ⇒ Object
Length in minutes.
-
#name ⇒ Object
Task name.
-
#running ⇒ Object
Task currently running bool.
Instance Method Summary collapse
-
#complete? ⇒ Boolean
Check if the task has been completed.
-
#initialize(name = nil, options = {}) ⇒ Task
constructor
Initialize with name and options.
-
#running? ⇒ Boolean
Check if the task currently running.
-
#start(config, options = {}) ⇒ Object
Start timing the task.
-
#to_s ⇒ Object
Quoted task name.
-
#verbose_output(format) ⇒ Object
Output verbose task information.
Constructor Details
#initialize(name = nil, options = {}) ⇒ Task
Initialize with name and options.
34 35 36 37 38 39 40 |
# File 'lib/pomo/task.rb', line 34 def initialize(name = nil, = {}) @name = name or raise '<task> required' @description = .delete :description @length = .fetch :length, 25 @running = false @complete = false end |
Instance Attribute Details
#complete ⇒ Object
Task completion bool.
29 30 31 |
# File 'lib/pomo/task.rb', line 29 def complete @complete end |
#description ⇒ Object
Verbose task description.
19 20 21 |
# File 'lib/pomo/task.rb', line 19 def description @description end |
#length ⇒ Object
Length in minutes.
14 15 16 |
# File 'lib/pomo/task.rb', line 14 def length @length end |
#name ⇒ Object
Task name.
9 10 11 |
# File 'lib/pomo/task.rb', line 9 def name @name end |
#running ⇒ Object
Task currently running bool.
24 25 26 |
# File 'lib/pomo/task.rb', line 24 def running @running end |
Instance Method Details
#complete? ⇒ Boolean
Check if the task has been completed.
59 60 61 |
# File 'lib/pomo/task.rb', line 59 def complete? complete end |
#running? ⇒ Boolean
Check if the task currently running.
52 53 54 |
# File 'lib/pomo/task.rb', line 52 def running? running end |
#start(config, options = {}) ⇒ Object
Start timing the task.
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/pomo/task.rb', line 76 def start(config, = {}) list = [:list] progress = [:progress] @running = true list.save unless list.nil? if progress foreground_progress(config) else background_progress(config) end end |
#to_s ⇒ Object
Quoted task name.
45 46 47 |
# File 'lib/pomo/task.rb', line 45 def to_s name end |
#verbose_output(format) ⇒ Object
Output verbose task information
66 67 68 69 70 71 |
# File 'lib/pomo/task.rb', line 66 def verbose_output(format) say format % ['name', self] say format % ['length', "#{length} minutes"] say format % ['description', description] if description and not description.empty? say format % ['complete', complete ? '[✓]' : '[ ]'] end |