Class: Timert::ArgumentParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ArgumentParser

Returns a new instance of ArgumentParser.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/timert/argument_parser.rb', line 7

def initialize(args)
  if args.empty?
    @action = "help"
    @argument = nil
  elsif is_api?(args[0])
    @action = args[0]
    @argument = api_argument(@action, *args[1..-1])
  else
    @action = 'add_task'
    @argument = args.join(" ")
  end
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



5
6
7
# File 'lib/timert/argument_parser.rb', line 5

def action
  @action
end

#argumentObject (readonly)

Returns the value of attribute argument.



5
6
7
# File 'lib/timert/argument_parser.rb', line 5

def argument
  @argument
end