Last active
December 18, 2016 14:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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