Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

introduce before_date filter

  • Loading branch information...
commit 288095266c912304b4a982c09cf4c631e1630c42 1 parent 547e7c0
authored March 14, 2013
4  lib/todotxt/todolist.rb
@@ -81,6 +81,10 @@ def on_date date
81 81
       @todos.select { |t| t.due == date }
82 82
     end
83 83
 
  84
+    def before_date date
  85
+      @todos.reject { |t| t.due.nil? || t.due >= date }
  86
+    end
  87
+
84 88
     def to_txt
85 89
       @todos.sort { |a,b| a.line <=> b.line }.map { |t| t.to_s.strip }.join("\n")
86 90
     end
7  spec/todolist_spec.rb
@@ -60,6 +60,13 @@
60 60
       @list.on_date(date).should eql [@list.todos.last]
61 61
     end
62 62
 
  63
+    it "fetchs items before a cereain date" do
  64
+      @list.add "2012-11-11 item"
  65
+      @list.add "2012-12-12 item"
  66
+      date = DateTime.parse("2012-12-12")
  67
+      @list.before_date(date).count.should eql 1
  68
+    end
  69
+
63 70
     it "includes done items in search when told to do so" do
64 71
       @list.filter "first", :with_done => true
65 72
 

0 notes on commit 2880952

Please sign in to comment.
Something went wrong with that request. Please try again.