Module: Tdo

Defined in:
lib/tdo.rb

Defined Under Namespace

Classes: InvalidGroup, Tasks

Constant Summary collapse

TODO_FILE =

If using ENV, path must be absolute

(ENV['TDO_FILE'] ? File.expand_path(ENV['TDO_FILE']) : File.expand_path("~/.todo.txt"))

Class Method Summary collapse

Class Method Details

.add(task, group = nil) ⇒ Object



217
218
219
# File 'lib/tdo.rb', line 217

def self.add(task, group=nil)
  Tdo::Tasks.new.add(task, group)
end

.clearObject



213
214
215
# File 'lib/tdo.rb', line 213

def self.clear
  Tdo::Tasks.new.clear
end

.get_group(str) ⇒ Object

Takes the groups name from a string



21
22
23
24
25
26
27
# File 'lib/tdo.rb', line 21

def self.get_group( str )
  if str[0] == '@'
    return str[1..-1]
  else
    return str
  end
end

.mark_done(id, group = nil) ⇒ Object



209
210
211
# File 'lib/tdo.rb', line 209

def self.mark_done(id, group=nil)
  Tdo::Tasks.new.mark_done(id, group)
end

.read_tasks(group = nil) ⇒ Object

These are a group of methods to make it easy to use the above class



205
206
207
# File 'lib/tdo.rb', line 205

def self.read_tasks(group=nil)
  Tdo::Tasks.new.to_s(group)
end

.summaryString

Gives a summary of remaining tasks

Returns:

  • (String)

    summary of tasks



12
13
14
15
16
17
18
# File 'lib/tdo.rb', line 12

def self.summary
  t = Tasks.new.items
  groups = t.size-1
  tasks = t.inject(0) {|sum, t| sum += t[1].size}
  done = t.inject(0) {|sum, t| sum += t[1].delete_if {|i| !i.include? ' #done' }.size}
  "#{tasks} tasks in #{groups} groups, #{done} done"
end