Class: Dooby::Task

Inherits:
Object
  • Object
show all
Includes:
Formateable
Defined in:
lib/dooby/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Formateable

#format

Constructor Details

#initializeTask

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

#priorityObject

Returns the value of attribute priority.



5
6
7
# File 'lib/dooby/task.rb', line 5

def priority
  @priority
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/dooby/task.rb', line 5

def status
  @status
end

#todoObject

Returns the value of attribute todo.



5
6
7
# File 'lib/dooby/task.rb', line 5

def todo
  @todo
end

Instance Method Details

#colorizeObject



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

#idObject



13
14
15
# File 'lib/dooby/task.rb', line 13

def id
  @todo ? Digest::SHA1.hexdigest(@todo)[0,6] : nil
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/dooby/task.rb', line 17

def valid?      
  @todo.nil? || @todo == '' ? false : true
end