Priorité et Notes correctements traitées

This commit is contained in:
Yann Esposito 2009-06-03 13:35:31 +02:00
parent edf17de477
commit e1c4dfe3b0

23
task.rb
View file

@ -18,6 +18,8 @@ class Task
res=@description res=@description
if (@contexts.length>0): res+=' ' + @contexts.map { |x| x.to_s }.join(" ") end if (@contexts.length>0): res+=' ' + @contexts.map { |x| x.to_s }.join(" ") end
if (@projects.length>0): res+=' ' + @projects.map { |x| '['+x.to_s+']' }.join(" ") end if (@projects.length>0): res+=' ' + @projects.map { |x| '['+x.to_s+']' }.join(" ") end
if (@priority != 0): res+=' /'+ @priority.to_s + '\\' end
if (@notes.length>0): res+=' ' + @notes.map { |x| '('+x.to_s+')' }.join(" ") end
if (@contacts.length>0): res+=' ' + @contacts.map { |x| x.to_s }.join(" ") end if (@contacts.length>0): res+=' ' + @contacts.map { |x| x.to_s }.join(" ") end
if (@dates): res+=' ' + @dates.to_s end if (@dates): res+=' ' + @dates.to_s end
if (@tags.length>0): res+=' ' + '{' + @tags.map{ |x| x.to_s }.join(", ") + '}' end if (@tags.length>0): res+=' ' + '{' + @tags.map{ |x| x.to_s }.join(", ") + '}' end
@ -32,6 +34,12 @@ class Task
if (@projects.length>0): if (@projects.length>0):
res+="\n projects:" + @projects.map { |x| '['+x.to_s+']' }.join(" ") res+="\n projects:" + @projects.map { |x| '['+x.to_s+']' }.join(" ")
end end
if (@priority != 0):
res+="\n priority: " + @priority.to_s
end
if (@notes.length>0):
res+="\n notes : " + @notes.map { |x| '('+x.to_s+')' }.join(" ")
end
if (@contacts.length>0): if (@contacts.length>0):
res+="\n contacts:" + @contacts.map { |x| x.to_s }.join(" ") res+="\n contacts:" + @contacts.map { |x| x.to_s }.join(" ")
end end
@ -56,7 +64,7 @@ class Task
# Contact # Contact
@@ContactsRegExp=Regexp.new(%{ (c|contact):#{@@StdTokenRegExp.inspect[1..-2]}}) @@ContactsRegExp=Regexp.new(%{ (c|contact):#{@@StdTokenRegExp.inspect[1..-2]}})
# Notes # Notes
@@NotesRegExp=Regexp.new(%{\\(#{@@StdTokenRegExp.inspect[1..-2]}\\)}) @@NotesRegExp=Regexp.new(%{\\(([^\)]*)\\)})
def from_s( raw_input ) def from_s( raw_input )
@ -76,6 +84,13 @@ class Task
end end
end end
current = Task.new("Coucou @Home #tomorrow"); task = Task.new("")
print current.to_detailled_s while true:
print "\n" print "> "
task.from_s( STDIN.gets.chomp )
print "------------\n"
print task.to_s
print "\n------------\n"
print task.to_detailled_s
print "\n------------\n"
end