Skip to content

Instantly share code, notes, and snippets.

@andmcgregor
Created June 21, 2013 17:52
Show Gist options
  • Save andmcgregor/5833005 to your computer and use it in GitHub Desktop.
Save andmcgregor/5833005 to your computer and use it in GitHub Desktop.
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