Class: Todos::Calendar
- Inherits:
-
Object
- Object
- Todos::Calendar
- Defined in:
- app/models/todos/calendar.rb
Instance Attribute Summary collapse
-
#included_tables ⇒ Object
readonly
Returns the value of attribute included_tables.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #actions ⇒ Object private
- #due_after_this_month ⇒ Object
- #due_next_week ⇒ Object
- #due_this_month ⇒ Object
- #due_this_week ⇒ Object
- #due_today ⇒ Object
- #end_of_next_week ⇒ Object
- #end_of_the_month ⇒ Object
- #end_of_the_week ⇒ Object
-
#initialize(user) ⇒ Calendar
constructor
A new instance of Calendar.
- #projects ⇒ Object
- #today ⇒ Object
Constructor Details
#initialize(user) ⇒ Calendar
Returns a new instance of Calendar.
5 6 7 8 |
# File 'app/models/todos/calendar.rb', line 5 def initialize(user) @user = user @included_tables = Todo::DEFAULT_INCLUDES end |
Instance Attribute Details
#included_tables ⇒ Object (readonly)
Returns the value of attribute included_tables.
3 4 5 |
# File 'app/models/todos/calendar.rb', line 3 def included_tables @included_tables end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/models/todos/calendar.rb', line 3 def user @user end |
Instance Method Details
#actions ⇒ Object (private)
52 53 54 |
# File 'app/models/todos/calendar.rb', line 52 def actions user.todos.not_completed.includes(included_tables).reorder("due") end |
#due_after_this_month ⇒ Object
30 31 32 |
# File 'app/models/todos/calendar.rb', line 30 def due_after_this_month actions.due_after(end_of_the_month) end |
#due_next_week ⇒ Object
22 23 24 |
# File 'app/models/todos/calendar.rb', line 22 def due_next_week actions.due_between(end_of_the_week, end_of_next_week) end |
#due_this_month ⇒ Object
26 27 28 |
# File 'app/models/todos/calendar.rb', line 26 def due_this_month actions.due_between(end_of_next_week, end_of_the_month) end |
#due_this_week ⇒ Object
18 19 20 |
# File 'app/models/todos/calendar.rb', line 18 def due_this_week actions.due_between(today, end_of_the_week) end |
#due_today ⇒ Object
14 15 16 |
# File 'app/models/todos/calendar.rb', line 14 def due_today actions.due_today end |
#end_of_next_week ⇒ Object
42 43 44 |
# File 'app/models/todos/calendar.rb', line 42 def end_of_next_week @end_of_next_week ||= end_of_the_week + 7.days end |
#end_of_the_month ⇒ Object
46 47 48 |
# File 'app/models/todos/calendar.rb', line 46 def end_of_the_month @end_of_the_month ||= today.end_of_month end |
#end_of_the_week ⇒ Object
38 39 40 |
# File 'app/models/todos/calendar.rb', line 38 def end_of_the_week @end_of_the_week ||= today.end_of_week end |
#projects ⇒ Object
10 11 12 |
# File 'app/models/todos/calendar.rb', line 10 def projects user.projects end |
#today ⇒ Object
34 35 36 |
# File 'app/models/todos/calendar.rb', line 34 def today @today ||= Time.zone.now end |