Class: Redpomo::TaskList
- Inherits:
-
Array
- Object
- Array
- Redpomo::TaskList
- Defined in:
- lib/redpomo/task_list.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add!(task) ⇒ Object
- #find(task_number) ⇒ Object
-
#initialize(path) ⇒ TaskList
constructor
A new instance of TaskList.
- #pull_from_trackers! ⇒ Object
- #remove!(task) ⇒ Object
- #write! ⇒ Object
Constructor Details
Class Method Details
.add!(task) ⇒ Object
17 18 19 20 |
# File 'lib/redpomo/task_list.rb', line 17 def self.add!(task) list = TaskList.new(Config.todo_path) list.add!(task) end |
Instance Method Details
#add!(task) ⇒ Object
38 39 40 41 |
# File 'lib/redpomo/task_list.rb', line 38 def add!(task) push task write! end |
#find(task_number) ⇒ Object
29 30 31 |
# File 'lib/redpomo/task_list.rb', line 29 def find(task_number) slice(task_number.to_i - 1) end |
#pull_from_trackers! ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/redpomo/task_list.rb', line 43 def pull_from_trackers! issue_tasks = Tracker.all.map(&:issues).flatten.map(&:to_task) delete_if do |task| task.tracker.present? end self << issue_tasks self.flatten! write! Redpomo.ui.info "Pulled #{issue_tasks.count} issues." end |
#remove!(task) ⇒ Object
33 34 35 36 |
# File 'lib/redpomo/task_list.rb', line 33 def remove!(task) delete(task) write! end |
#write! ⇒ Object
54 55 56 57 58 |
# File 'lib/redpomo/task_list.rb', line 54 def write! File.open(@path, 'w') do |file| file.write map(&:orig).join("\n") + "\n" end end |