Module: Gyunyu::Command::Export::CustomFilter
- Defined in:
- lib/gyunyu/command/export/custom_filter.rb
Constant Summary collapse
- START_SECOND =
'T23:59:59Z'- LAST_SECOND =
'T24:00:00Z'
Class Method Summary collapse
- .filter ⇒ Object
- .from_last_month ⇒ Object
- .from_last_week ⇒ Object
- .from_next_month ⇒ Object
- .from_next_week ⇒ Object
- .from_this_month ⇒ Object
- .from_this_week ⇒ Object
- .from_today ⇒ Object
- .from_tomorrow ⇒ Object
- .from_yesterday ⇒ Object
- .incomplete ⇒ Object
- .last_sunday ⇒ Object
- .next_sunday ⇒ Object
- .today ⇒ Object
- .until_last_month ⇒ Object
- .until_last_week ⇒ Object
- .until_next_month ⇒ Object
- .until_next_week ⇒ Object
- .until_this_month ⇒ Object
- .until_this_week ⇒ Object
- .until_today ⇒ Object
- .until_tomorrow ⇒ Object
- .until_yesterday ⇒ Object
Class Method Details
.filter ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 13 def filter filter = {} %w( yesterday today tomorrow last_week this_week next_week last_month this_month next_month ).each { |term| due = [ "dueAfter:" + send("from_#{term}"), "dueBefore:" + send("until_#{term}") ].join( ' and ' ) filter[term] = due filter["#{term}_yet"] = due + incomplete } filter end |
.from_last_month ⇒ Object
115 116 117 118 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 115 def from_last_month d = today << 2 Date.new( d.year, d.mon, -1 ).to_s + START_SECOND end |
.from_last_week ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 79 def from_last_week if today.sunday? (last_sunday - 1).to_s + START_SECOND else (last_sunday - 8).to_s + START_SECOND end end |
.from_next_month ⇒ Object
135 136 137 138 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 135 def from_next_month d = today Date.new( d.year, d.mon, -1 ).to_s + START_SECOND end |
.from_next_week ⇒ Object
107 108 109 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 107 def from_next_week (next_sunday - 1).to_s + START_SECOND end |
.from_this_month ⇒ Object
125 126 127 128 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 125 def from_this_month d = today << 1 Date.new( d.year, d.mon, -1 ).to_s + START_SECOND end |
.from_this_week ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 95 def from_this_week if today.sunday? (today - 1).to_s + START_SECOND else (last_sunday - 1).to_s + START_SECOND end end |
.from_today ⇒ Object
63 64 65 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 63 def from_today (today - 1).to_s + START_SECOND end |
.from_tomorrow ⇒ Object
71 72 73 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 71 def from_tomorrow today.to_s + START_SECOND end |
.from_yesterday ⇒ Object
55 56 57 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 55 def from_yesterday (today - 2).to_s + START_SECOND end |
.incomplete ⇒ Object
145 146 147 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 145 def incomplete ' and status:incomplete' end |
.last_sunday ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 29 def last_sunday if today.sunday? today - 7 else proc { |d| until d.sunday? d -= 1 end d }.call(today) end end |
.next_sunday ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 42 def next_sunday if today.sunday? today + 7 else proc { |d| until d.sunday? d += 1 end d }.call(today) end end |
.today ⇒ Object
9 10 11 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 9 def today Date.today end |
.until_last_month ⇒ Object
120 121 122 123 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 120 def until_last_month d = today << 1 Date.new( d.year, d.mon, -1 ).to_s + LAST_SECOND end |
.until_last_week ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 87 def until_last_week if today.sunday? (today - 1).to_s + LAST_SECOND else (last_sunday - 1).to_s + LAST_SECOND end end |
.until_next_month ⇒ Object
140 141 142 143 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 140 def until_next_month d = today >> 1 Date.new( d.year, d.mon, -1 ).to_s + LAST_SECOND end |
.until_next_week ⇒ Object
111 112 113 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 111 def until_next_week (next_sunday + 6).to_s + LAST_SECOND end |
.until_this_month ⇒ Object
130 131 132 133 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 130 def until_this_month d = today Date.new( d.year, d.mon, -1 ).to_s + LAST_SECOND end |
.until_this_week ⇒ Object
103 104 105 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 103 def until_this_week (next_sunday - 1).to_s + LAST_SECOND end |
.until_today ⇒ Object
67 68 69 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 67 def until_today today.to_s + LAST_SECOND end |
.until_tomorrow ⇒ Object
75 76 77 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 75 def until_tomorrow (today + 1).to_s + LAST_SECOND end |
.until_yesterday ⇒ Object
59 60 61 |
# File 'lib/gyunyu/command/export/custom_filter.rb', line 59 def until_yesterday (today - 1).to_s + LAST_SECOND end |