class Taskmeister::Task
Attributes
id[R]
notes[R]
text[R]
Public Class Methods
create(text)
click to toggle source
# File lib/taskmeister/task.rb, line 23 def self.create(text) self.new(text, SecureRandom.uuid, [""]) end
from_markdown(lines)
click to toggle source
# File lib/taskmeister/task.rb, line 27 def self.from_markdown(lines) task, *notes = *lines text, id = task_attributes(task) self.new(text, id, notes) end
new(text, id, notes)
click to toggle source
# File lib/taskmeister/task.rb, line 9 def initialize(text, id, notes) @text, @id, @notes = text, id, Array(notes) end
task_attributes(line)
click to toggle source
# File lib/taskmeister/task.rb, line 35 def self.task_attributes(line) matches = line.match(/#\s(.+)\s\[∞\]\(#([\w-]+)\)/) fail "Invalid task: #{line}" unless matches [matches[1], matches[2]] end
Public Instance Methods
notes?()
click to toggle source
# File lib/taskmeister/task.rb, line 13 def notes? notes.any? { |ns| !ns.empty? } end
to_markdown()
click to toggle source
# File lib/taskmeister/task.rb, line 17 def to_markdown [ "# #{text} [∞](##{id})" ].tap do |a| a.concat notes end end