Created
June 21, 2013 17:52
-
-
Save andmcgregor/5833005 to your computer and use it in GitHub Desktop.
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 ToDoView | |
| def initialize | |
| list if ARGV.include? 'list' | |
| add if ARGV.include? 'add' | |
| delete if ARGV.include? 'delete' | |
| end | |
| def list | |
| list = ARGV[1] ? TodoController::list({ list: ARGV[1] }) : TodoController::list | |
| puts list.map {|task| (task.completed ? "\033[92m✔\033[0m " : "\033[91m✘\033[0m ") + task.name.to_s } # .join("\n") | |
| end | |
| def add | |
| TodoController::add({ name: ARGV[1..-1].join(" ") }) # sends name of task | |
| end | |
| def delete | |
| TodoController::delete({ id: ARGV[1..-1] }) # sends id of task | |
| end | |
| end | |
| ToDoView.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment