Class: R2do::Commands::NowCommand

Inherits:
R2do::Command show all
Defined in:
lib/r2do/commands/now_command.rb

Instance Attribute Summary

Attributes inherited from R2do::Command

#description, #extended, #short

Instance Method Summary collapse

Methods inherited from R2do::Command

#to_s

Constructor Details

#initialize(state) ⇒ NowCommand

Returns a new instance of NowCommand.



21
22
23
24
25
# File 'lib/r2do/commands/now_command.rb', line 21

def initialize(state)
  super('n', 'now', 'Displays the information for the current category.')

  @state = state
end

Instance Method Details

#display_current_category(args) ⇒ void

This method returns an undefined value.

Shows the detailed information for the current category, including the tasks contained

Parameters:

  • args (Array)

    the arguments passed to the app by the user



41
42
43
44
45
46
47
48
49
# File 'lib/r2do/commands/now_command.rb', line 41

def display_current_category(args)
  #TODO: need to refatctor the code to remove the duplication
  if not @state.current_category
    UI.status("No category is currently selected.")
  else
    UI.status(@state.current_category.to_s)
    UI.new_line()
  end
end

#execute(args) ⇒ void

This method returns an undefined value.

Creates a new category or makes a category current in the state if a category with the same name already exists

Parameters:

  • args (Array)

    the arguments passed to the app by the user

Raises:

  • (ArgumentError)

    if the command does not contain a name for the category



33
34
35
# File 'lib/r2do/commands/now_command.rb', line 33

def execute(args)
  display_current_category(args)
end

#helpObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/r2do/commands/now_command.rb', line 51

def help()
  help = <<-EOF
NAME
 r2do #{@extended}

SYNOPSIS
 'r2do #{@extended}' or 'r2do #{@short}' are equivalent

DESCRIPTION
The #{@extended} lets view the current category and its tasks

usage: r2do #{@extended}

  EOF
end