Class: TodoVoid

Inherits:
Object
  • Object
show all
Defined in:
lib/todo_void.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = [], interactor = TodoInteractor.new) ⇒ TodoVoid

Returns a new instance of TodoVoid.



6
7
8
9
10
# File 'lib/todo_void.rb', line 6

def initialize(args=[], interactor = TodoInteractor.new)
  @todo_interactor = interactor
  @args = args
  @output = ""
end

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/todo_void.rb', line 12

def execute
  if flag?('-d')
    change_status(:deleted)
  elsif flag?('-f')
    change_status(:finished)
  elsif flag?('-s')
    change_status(:started)
  elsif flag?('--help')
    @output = read_help
  elsif @args[0]
    tags = extract_tags(@args[1])
    @todo_interactor.add_todo(@args[0], tags)
  else
    todos = TodoInteractor.new.list_all
    @output = TodoListView.render(todos)
  end
  @output
end