Class: Commands::ListCommand

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

Instance Method Summary collapse

Constructor Details

#initialize(tracker) ⇒ ListCommand

Returns a new instance of ListCommand.



9
10
11
# File 'lib/commands/listcommand.rb', line 9

def initialize(tracker)
  @tracker = tracker
end

Instance Method Details

#help(commandcontext) ⇒ Object



24
25
26
# File 'lib/commands/listcommand.rb', line 24

def help(commandcontext)
  commandcontext.output 'Use pug list [type [status]]'
end

#run(commandcontext) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/commands/listcommand.rb', line 13

def run(commandcontext)
  type = commandcontext.pop_argument!.downcase if commandcontext.number_of_arguments > 0
  status = commandcontext.pop_argument!.downcase if commandcontext.number_of_arguments > 0

  @tracker.all {|x|
    if (x.type.downcase == type || type == nil) && (x.status.downcase == status || status == nil)
      commandcontext.output(x)
    end
  }
end