Class: TaskList
- Inherits:
-
Object
- Object
- TaskList
- Defined in:
- lib/todoNotifier/TaskList.rb
Instance Attribute Summary collapse
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
-
#initialize ⇒ TaskList
constructor
A new instance of TaskList.
- #parseLine(l) ⇒ Object
Constructor Details
#initialize ⇒ TaskList
Returns a new instance of TaskList.
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.("~/.todo"), "r") f.each do |l| m = parseLine(l) if m tasks << Task.new(m) end end f.close end |
Instance Attribute Details
#tasks ⇒ Object
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 |