Class: Todos::Calendar

Inherits:
Object
  • Object
show all
Defined in:
app/models/todos/calendar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tablesObject (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

#userObject (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

#actionsObject (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_monthObject



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_weekObject



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_monthObject



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_weekObject



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_todayObject



14
15
16
# File 'app/models/todos/calendar.rb', line 14

def due_today
  actions.due_today
end

#end_of_next_weekObject



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_monthObject



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_weekObject



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

#projectsObject



10
11
12
# File 'app/models/todos/calendar.rb', line 10

def projects
  user.projects
end

#todayObject



34
35
36
# File 'app/models/todos/calendar.rb', line 34

def today
  @today ||= Time.zone.now
end