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



6
7
8
9
# File 'app/models/todos/calendar.rb', line 6

def initialize(user)
  @user = user
  @included_tables = Todo::DEFAULT_INCLUDES
end

Instance Attribute Details

#included_tablesObject (readonly)

Returns the value of attribute included_tables



4
5
6
# File 'app/models/todos/calendar.rb', line 4

def included_tables
  @included_tables
end

#userObject (readonly)

Returns the value of attribute user



4
5
6
# File 'app/models/todos/calendar.rb', line 4

def user
  @user
end

Instance Method Details

#actionsObject (private)



53
54
55
# File 'app/models/todos/calendar.rb', line 53

def actions
  user.todos.not_completed.includes(included_tables).reorder("due")
end

#due_after_this_monthObject



31
32
33
# File 'app/models/todos/calendar.rb', line 31

def due_after_this_month
  actions.due_after(end_of_the_month)
end

#due_next_weekObject



23
24
25
# File 'app/models/todos/calendar.rb', line 23

def due_next_week
  actions.due_between(end_of_the_week, end_of_next_week)
end

#due_this_monthObject



27
28
29
# File 'app/models/todos/calendar.rb', line 27

def due_this_month
  actions.due_between(end_of_next_week, end_of_the_month)
end

#due_this_weekObject



19
20
21
# File 'app/models/todos/calendar.rb', line 19

def due_this_week
  actions.due_between(today, end_of_the_week)
end

#due_todayObject



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

def due_today
  actions.due_today
end

#end_of_next_weekObject



43
44
45
# File 'app/models/todos/calendar.rb', line 43

def end_of_next_week
  @end_of_next_week ||= end_of_the_week + 7.days
end

#end_of_the_monthObject



47
48
49
# File 'app/models/todos/calendar.rb', line 47

def end_of_the_month
  @end_of_the_month ||= today.end_of_month
end

#end_of_the_weekObject



39
40
41
# File 'app/models/todos/calendar.rb', line 39

def end_of_the_week
  @end_of_the_week ||= today.end_of_week
end

#projectsObject



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

def projects
  user.projects
end

#todayObject



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

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