Created
October 15, 2012 08:46
-
-
Save BrianJoyce/3891505 to your computer and use it in GitHub Desktop.
todo_stuff
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 Todo | |
| @@todo_id = 0 | |
| attr_accessor :todo | |
| def initialize(todo) | |
| @todo = {} | |
| text(todo) | |
| date_time(Time.now) | |
| todo_id | |
| end | |
| def todo_id | |
| @todo.merge!(:id => @@todo_id) | |
| @@todo_id +=1 | |
| end | |
| def complete? | |
| @todo[complete] | |
| end | |
| def tags(tag) | |
| @todo.merge!(:tag => tag) | |
| end | |
| def text(text) | |
| @todo.merge!(:text => text) | |
| end | |
| def date_time(time=Time.now) | |
| @todo.merge!(:time => time) | |
| end | |
| end | |
| my_todo = Todo.new("this is a test") | |
| puts my_todo.inspect | |
| my_todo2 = Todo.new("this is a test too") | |
| puts my_todo2.inspect | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment