Class: PlannedTimetableSlot

Inherits:
RolePlaying::Role
  • Object
show all
Defined in:
app/roles/planned_timetable_slot.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj, time_converter) ⇒ PlannedTimetableSlot

Returns a new instance of PlannedTimetableSlot.


6
7
8
9
# File 'app/roles/planned_timetable_slot.rb', line 6

def initialize(obj, time_converter)
  super obj
  @time_converter = time_converter
end

Instance Method Details

#clear_extra_events(planned_events) ⇒ Object


19
20
21
22
23
# File 'app/roles/planned_timetable_slot.rb', line 19

def clear_extra_events(planned_events)
  all_events = Event.where(source_type: 'timetable_slot', source_id: id.to_s, deleted: false)
  extra_events = filter_extra_events(all_events, planned_events)
  Event.batch_delete(extra_events.map(&:id))
end

#dayObject


25
26
27
28
29
30
31
32
# File 'app/roles/planned_timetable_slot.rb', line 25

def day
  original_day = __getobj__.day
  if original_day.is_a? Numeric
    Day.values[original_day]
  else
    original_day
  end
end

#generate_events(faculty_semester, semester_period) ⇒ Object


11
12
13
14
15
16
17
# File 'app/roles/planned_timetable_slot.rb', line 11

def generate_events(faculty_semester, semester_period)
  teaching_time = generate_teaching_time
  event_periods = semester_period.plan(teaching_time)
  create_events(event_periods, faculty_semester).tap do |events|
    events.map { |e| e.deleted = !!deleted_at }
  end
end