Method: MMToDo::ToDoApp#check_selection

Defined in:
lib/mm_todo/todo_app.rb

#check_selection(selection) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mm_todo/todo_app.rb', line 68

def check_selection(selection)
	if selection !~ /^\d+$/
		@error = "[Invalid selection] Just the number, please."
		return
	elsif selection.to_i == 0 || selection.to_i > @list.size
		@error = "[Invalid selection] No todo with that number."
		return
	end
	
	index = selection.to_i
	@error = "(Item completed: #{@list.select(index)})"
	@list.select(index).do
end