Class: TaskList

Inherits:
Object
  • Object
show all
Defined in:
lib/todoNotifier/TaskList.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTaskList



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/todoNotifier/TaskList.rb', line 15

def initialize()
  self.tasks = []
  f = File.open(File.expand_path("~/.todo"), "r")
  f.each do |l|
    m = parseLine(l)
    if m
      tasks << Task.new(m)
    end
  end
  f.close
end

Instance Attribute Details

#tasksObject

Returns the value of attribute tasks.



2
3
4
# File 'lib/todoNotifier/TaskList.rb', line 2

def tasks
  @tasks
end

Instance Method Details

#parseLine(l) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/todoNotifier/TaskList.rb', line 4

def parseLine(l)
  # Capitals denote a title, so block them (2 or more)
  if l =~ /^[:upper:]+$/
    return
  end
  # Matches '-', '*', '#', tabs or 2 or more spaces as the beginning of a task
  if l =~ /^(-|\*|\#|\t|\s{2,})(.*)/
    return $2 # Return the message
  end
end