Skip to content

Instantly share code, notes, and snippets.

@sirupsen
Last active December 18, 2016 14:39
Show Gist options
  • Save sirupsen/382000 to your computer and use it in GitHub Desktop.
Save sirupsen/382000 to your computer and use it in GitHub Desktop.
Template I was given by someone on #ruby to implement a simple Todo List application in Ruby many years ago.
Class TodoList
def self.load(file)
# read the file, create a list, create items, add them
end
def initialize
end
def add(item)
end
def write(file)
# write the file, only write the undone items
end
def [](id)
@list[id]
end
end
class TodoItem
# provide reader and setter for name and state
def initialize(name)
# store name
# set state to undone
end
end
# ---
# the library will be used like this:
# list = TodoList.load("todo.td")
# list[0].done = true
# list.add TodoItem.new("another cool item")
# list.write("todo.td")
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment