Class: Dooby::Task
- Extended by:
- StatusGenerator
- Defined in:
- lib/dooby/task.rb
Instance Attribute Summary collapse
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#todo ⇒ Object
Returns the value of attribute todo.
Instance Method Summary collapse
- #colorize ⇒ Object
- #id ⇒ Object
-
#initialize(todo = nil) ⇒ Task
constructor
A new instance of Task.
- #valid? ⇒ Boolean
Constructor Details
#initialize(todo = nil) ⇒ Task
Returns a new instance of Task.
8 9 10 |
# File 'lib/dooby/task.rb', line 8 def initialize (todo = nil) @todo = todo 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 |
#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
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dooby/task.rb', line 20 def colorize colorized_todo = @todo.dup string_pattern = SPECIAL_CHARS.collect { |c| "(#{c}\\w+)" } pattern = Regexp.new(string_pattern.join("|")) colorized_todo.gsub(pattern) do |todo| color = SPECIAL_CHAR_COLORS[todo.first_char] todo.send color end end |
#id ⇒ Object
12 13 14 |
# File 'lib/dooby/task.rb', line 12 def id @todo ? Digest::SHA1.hexdigest(@todo)[0,6] : nil end |
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/dooby/task.rb', line 16 def valid? @todo.nil? || @todo == '' ? false : true end |