class Task
Constants
- STATUS
Attributes
date_created[RW]
id[R]
stage[RW]
title[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/doneski/task.rb, line 7 def initialize(options) @id = options['id'] || (0...4).map { ('a'..'z').to_a[rand(26)] }.join @title = options['title'] @stage = options['stage'] || STATUS[:new] @date_created = options['date_created'] || Time.now @priority = options['priority'] || '' end
Public Instance Methods
complete()
click to toggle source
# File lib/doneski/task.rb, line 15 def complete @stage = STATUS[:complete] end
match(options)
click to toggle source
# File lib/doneski/task.rb, line 35 def match(options) options.each{|key, value| return true if self.send(key) == value} false end
priority()
click to toggle source
# File lib/doneski/task.rb, line 19 def priority !@priority.nil? ? -@priority.length : nil end
priority=(priority)
click to toggle source
# File lib/doneski/task.rb, line 23 def priority=(priority) if priority.nil? @priority = '' else @priority = priority.match(/\+{1,}/)[0] unless priority.nil? end end
start()
click to toggle source
# File lib/doneski/task.rb, line 31 def start @stage = STATUS[:started] end
to_s()
click to toggle source
# File lib/doneski/task.rb, line 40 def to_s "| \e[0;3#{stage.to_s}m#{id.to_s.ljust(8)}#{title.ljust(80)[0...80]}#{date_created.to_s.ljust(30)}#{@priority.ljust(10)}\e[0m |" end