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.(ENV['TDO_FILE']) : File.("~/.todo.txt"))
Class Method Summary collapse
- .add(task, group = nil) ⇒ Object
- .clear ⇒ Object
-
.get_group(str) ⇒ Object
Takes the groups name from a string.
- .mark_done(id, group = nil) ⇒ Object
-
.read_tasks(group = nil) ⇒ Object
These are a group of methods to make it easy to use the above class.
-
.summary ⇒ String
Gives a summary of remaining tasks.
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 |
.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 |
.summary ⇒ String
Gives a summary of remaining 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 |