Class: Markdo::TaskCollection
- Inherits:
-
Object
- Object
- Markdo::TaskCollection
- Defined in:
- lib/markdo/models/task_collection.rb
Instance Method Summary collapse
- #all ⇒ Object
- #deferred_until_today ⇒ Object
- #due_between(begin_date, end_date) ⇒ Object
- #due_on(given_date) ⇒ Object
- #due_soon ⇒ Object
- #due_today ⇒ Object
- #due_tomorrow ⇒ Object
-
#initialize(lines, today = Date.today) ⇒ TaskCollection
constructor
A new instance of TaskCollection.
- #overdue ⇒ Object
- #starred ⇒ Object
- #with_attribute(tag) ⇒ Object
- #with_match(matcher) ⇒ Object
- #with_tag(tag) ⇒ Object
Constructor Details
#initialize(lines, today = Date.today) ⇒ TaskCollection
Returns a new instance of TaskCollection.
6 7 8 9 |
# File 'lib/markdo/models/task_collection.rb', line 6 def initialize(lines, today = Date.today) @lines = lines @today = today end |
Instance Method Details
#all ⇒ Object
11 12 13 |
# File 'lib/markdo/models/task_collection.rb', line 11 def all tasks end |
#deferred_until_today ⇒ Object
55 56 57 |
# File 'lib/markdo/models/task_collection.rb', line 55 def deferred_until_today with_date('defer') { |date| date <= @today } end |
#due_between(begin_date, end_date) ⇒ Object
35 36 37 |
# File 'lib/markdo/models/task_collection.rb', line 35 def due_between(begin_date, end_date) with_date('due') { |date| date >= begin_date && date <= end_date } end |
#due_on(given_date) ⇒ Object
31 32 33 |
# File 'lib/markdo/models/task_collection.rb', line 31 def due_on(given_date) with_date('due') { |date| date == given_date } end |
#due_soon ⇒ Object
51 52 53 |
# File 'lib/markdo/models/task_collection.rb', line 51 def due_soon due_between(@today + 2, @today + 7) end |
#due_today ⇒ Object
43 44 45 |
# File 'lib/markdo/models/task_collection.rb', line 43 def due_today due_on(@today) end |
#due_tomorrow ⇒ Object
47 48 49 |
# File 'lib/markdo/models/task_collection.rb', line 47 def due_tomorrow due_on(@today + 1) end |
#overdue ⇒ Object
39 40 41 |
# File 'lib/markdo/models/task_collection.rb', line 39 def overdue with_date('due') { |date| date < @today } end |
#starred ⇒ Object
27 28 29 |
# File 'lib/markdo/models/task_collection.rb', line 27 def starred with_tag('star') end |
#with_attribute(tag) ⇒ Object
19 20 21 |
# File 'lib/markdo/models/task_collection.rb', line 19 def with_attribute(tag) with_tag(tag) end |
#with_match(matcher) ⇒ Object
23 24 25 |
# File 'lib/markdo/models/task_collection.rb', line 23 def with_match(matcher) tasks.select { |task| task.line.match(matcher) } end |
#with_tag(tag) ⇒ Object
15 16 17 |
# File 'lib/markdo/models/task_collection.rb', line 15 def with_tag(tag) tasks.select { |task| task.attributes[tag.downcase] } end |