Class: Wonde::LessonRegister

Inherits:
Object
  • Object
show all
Defined in:
lib/writeback/lessonregister.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLessonRegister

Returns a new instance of LessonRegister.



4
5
6
# File 'lib/writeback/lessonregister.rb', line 4

def initialize()
  self.attendance = Array.new()
end

Instance Attribute Details

#attendanceObject

Returns the value of attribute attendance.



3
4
5
# File 'lib/writeback/lessonregister.rb', line 3

def attendance
  @attendance
end

Instance Method Details

#add(lessonAttendance) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/writeback/lessonregister.rb', line 12

def add(lessonAttendance)
  newlessonattendance = Array.new()
  newlessonattendance.push(lessonAttendance)
  newlessonattendance.each do |lessonAttendanceSingular|
    if lessonAttendanceSingular.class == LessonAttendanceRecord && lessonAttendanceSingular.isValid()
      self.attendance = lessonAttendanceSingular.toArray()
    else
      unless lessonAttendanceSingular.class == LessonAttendanceRecord
        throw InvalidLessonAttendanceException, 'Attendance is not an instance of the LessonAttendance Class.'
      end
      unless lessonAttendanceSingular.isValid()
        throw InvalidLessonAttendanceException, 'Attendance has empty fields.'
      end
        throw InvalidLessonAttendanceException
    end
  end
end

#to_jsonObject



8
9
10
# File 'lib/writeback/lessonregister.rb', line 8

def to_json()
        {'attendance' => [self.attendance]}.to_json
end