Class: Timelog::Command::Archive

Inherits:
Timelog::Command show all
Defined in:
lib/timelog/command/archive.rb

Instance Attribute Summary

Attributes inherited from Timelog::Command

#arguments, #book, #session

Instance Method Summary collapse

Methods inherited from Timelog::Command

get, inherited, #initialize, known, register, #time_in_arguments

Constructor Details

This class inherits a constructor from Timelog::Command

Instance Method Details

#executeObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/timelog/command/archive.rb', line 4

def execute
  entries = book.entries.where(arguments.first || "non-archived")
  entries.delete_if {|e| not e.stopped? or e.archived}
  if entries.size == 0
    "no entries found for archiving"
  else
    entries.each do |e|
      book.entries.archive e
    end
    "#{entries.length} #{entries.length == 1 ? "entry" : "entries"} archived"
  end
end

#helpObject



17
18
19
# File 'lib/timelog/command/archive.rb', line 17

def help
  "usage: timelog archive [<query>]"
end