Class: Sirius::EventFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/sirius/event_factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(slot, faculty_semester) ⇒ EventFactory

Returns a new instance of EventFactory.


6
7
8
9
# File 'lib/sirius/event_factory.rb', line 6

def initialize(slot, faculty_semester)
  @slot = slot
  @faculty_semester = faculty_semester
end

Instance Method Details

#build_event(event_period, absolute_seq) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sirius/event_factory.rb', line 18

def build_event(event_period, absolute_seq)
  event = Event.new
  event.period = event_period
  event.absolute_sequence_number = absolute_seq
  event.deleted = false
  event.faculty = @faculty_semester.faculty
  event.semester = @faculty_semester.code
  event.applied_schedule_exception_ids = nil
  event.source_id = @slot.id
  if @slot.respond_to? :parallel
    event.parallel = @slot.parallel
    event.course = @slot.parallel.course
    event.event_type = @slot.parallel.parallel_type
    event.capacity = @slot.parallel.capacity
    event.source_type = 'timetable_slot'
  else
    event.source_type = 'teacher_timetable_slot'
  end
  event.room = @slot.room if @slot.respond_to? :room
  event
end

#build_events(periods) ⇒ Object


11
12
13
14
15
16
# File 'lib/sirius/event_factory.rb', line 11

def build_events(periods)
  absolute_seq = 0
  periods.map do |period|
    build_event(period, absolute_seq += 1)
  end
end