Skip to content

Instantly share code, notes, and snippets.

@taylor
Created January 26, 2009 08:35
Show Gist options
  • Select an option

  • Save taylor/52750 to your computer and use it in GitHub Desktop.

Select an option

Save taylor/52750 to your computer and use it in GitHub Desktop.
throw away idea code for task notes
require 'date'
class Task
@note = nil
def note=(s, action=nil)
if @note.nil?
@note = Note.new(s)
elsif action.nil?
@note.modify(s)
else
@note.modify(s, action)
end
end
def note
if @note.nil?
return nil
else
return @note.get_note()
end
end
end
class Note
@notes = nil
def initialize(s)
@notes = {:first => s}
end
def get_note
return nil if @notes.nil?
d=Date.today
if @notes[d].nil?
if @notes[:future]
return @notes[:future]
else
return @notes[:first]
end
else
return @notes[d]
end
end
def modify(s, action=:today)
return nil if @notes.nil?
case action
when :today
@notes[Date.today] = s
when :future
@notes[:future] = s
when :all
@notes = nil
@notes = {:first => s}
end
end
end
t = Task.new
t.note = "pastie"
puts t.note
t.note = "rabbit"
puts t.note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment