class Ruboty::Todo::Item
Constants
- ATTRIBUTES
- EMOTICONS
- STATUSES
Public Class Methods
new(id, params)
click to toggle source
# File lib/ruboty/todo/item.rb, line 16 def initialize(id, params) self.id = id self.status = :not_yet ATTRIBUTES.each do |attr| self.send("#{attr}=".to_sym, params[attr]) if params.key?(attr) end end
Public Instance Methods
deadline=(deadline)
click to toggle source
# File lib/ruboty/todo/item.rb, line 48 def deadline=(deadline) self.deadline_at = Time.parse(deadline) rescue nil end
delete()
click to toggle source
# File lib/ruboty/todo/item.rb, line 40 def delete self.status = :deleted end
deleted?()
click to toggle source
# File lib/ruboty/todo/item.rb, line 44 def deleted? self.status == :deleted end
doing?()
click to toggle source
# File lib/ruboty/todo/item.rb, line 28 def doing? self.status == :doing end
done?()
click to toggle source
# File lib/ruboty/todo/item.rb, line 36 def done? self.status == :done end
finish()
click to toggle source
# File lib/ruboty/todo/item.rb, line 32 def finish self.status = :done end
format(new_item: false)
click to toggle source
# File lib/ruboty/todo/item.rb, line 52 def format(new_item: false) emoticon_state = new_item ? :new : status "[#{sprintf('%2d', id)}] :#{EMOTICONS[emoticon_state]}: #{title}" end
start()
click to toggle source
# File lib/ruboty/todo/item.rb, line 24 def start self.status = :doing end