Class: Dooby::Task
Instance Attribute Summary collapse
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#status ⇒ Object
Returns the value of attribute status.
-
#todo ⇒ Object
Returns the value of attribute todo.
Instance Method Summary collapse
- #colorize ⇒ Object
- #doing! ⇒ Object
- #done! ⇒ Object
- #hold! ⇒ Object
- #id ⇒ Object
-
#initialize ⇒ Task
constructor
A new instance of Task.
- #valid? ⇒ Boolean
Methods included from Formateable
Constructor Details
#initialize ⇒ Task
Returns a new instance of Task.
7 8 9 10 11 |
# File 'lib/dooby/task.rb', line 7 def initialize @todo ||= nil @status ||= DEFAULT_STATUS @priority ||= DEFAULT_PRIORITY end |
Instance Attribute Details
#priority ⇒ Object
Returns the value of attribute priority.
5 6 7 |
# File 'lib/dooby/task.rb', line 5 def priority @priority end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/dooby/task.rb', line 5 def status @status end |
#todo ⇒ Object
Returns the value of attribute todo.
5 6 7 |
# File 'lib/dooby/task.rb', line 5 def todo @todo end |
Instance Method Details
#colorize ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dooby/task.rb', line 33 def colorize colorized_todo = @todo.dup colorized_todo.gsub(/(#\w+)|(@\w+)|(%\w+)/).each do |todo| if todo.include? "@" todo.blue elsif todo.include? "%" todo.white else todo.yellow end end end |
#doing! ⇒ Object
21 22 23 |
# File 'lib/dooby/task.rb', line 21 def doing! @status = :doing end |
#done! ⇒ Object
25 26 27 |
# File 'lib/dooby/task.rb', line 25 def done! @status = :done end |
#hold! ⇒ Object
29 30 31 |
# File 'lib/dooby/task.rb', line 29 def hold! @status = :hold end |
#id ⇒ Object
13 14 15 |
# File 'lib/dooby/task.rb', line 13 def id @todo ? Digest::SHA1.hexdigest(@todo)[0,6] : nil end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/dooby/task.rb', line 17 def valid? @todo.nil? || @todo == '' ? false : true end |