Class: Ztodo::Controller

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

Overview

Class for processing user commands.

This class uses Ztodo::Project and Ztodo::Converter classes

Instance Method Summary collapse

Constructor Details

#initializeController

Returns a new instance of Controller.



8
9
10
11
# File 'lib/ztodo/controller.rb', line 8

def initialize
  @proj = Ztodo::Project.new
  @conv = Ztodo::Converter.new
end

Instance Method Details

#execute!(args) ⇒ Object

Execute necessary command



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ztodo/controller.rb', line 14

def execute! args
  return cmd_list if args.empty?

  handler = args[0]

  if methods.include? ('cmd_'+handler).to_sym
    args.slice! 0
    method(('cmd_'+handler).to_sym).call args
  else
    cmd_help
  end
end