Class: Wonde::LessonRegister
- Inherits:
-
Object
- Object
- Wonde::LessonRegister
- Defined in:
- lib/writeback/lessonregister.rb
Instance Attribute Summary collapse
-
#attendance ⇒ Object
Returns the value of attribute attendance.
Instance Method Summary collapse
- #add(lessonAttendance) ⇒ Object
-
#initialize ⇒ LessonRegister
constructor
A new instance of LessonRegister.
- #to_json ⇒ Object
Constructor Details
#initialize ⇒ LessonRegister
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
#attendance ⇒ Object
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_json ⇒ Object
8 9 10 |
# File 'lib/writeback/lessonregister.rb', line 8 def to_json() {'attendance' => [self.attendance]}.to_json end |