Class: Wonde::SessionAttendanceRecord

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attendance_code_idObject

Returns the value of attribute attendance_code_id.



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

def attendance_code_id
  @attendance_code_id
end

#commentObject

Returns the value of attribute comment.



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

def comment
  @comment
end

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

#sessionObject

Returns the value of attribute session.



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

def session
  @session
end

#student_idObject

Returns the value of attribute student_id.



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

def student_id
  @student_id
end

Instance Method Details

#getAttendanceCodeIdObject



56
57
58
# File 'lib/writeback/sessionattendancerecord.rb', line 56

def getAttendanceCodeId()
    return self.attendance_code_id
end

#getCommentObject



81
82
83
# File 'lib/writeback/sessionattendancerecord.rb', line 81

def getComment()
    return self.comment;
end

#getDateObject



60
61
62
# File 'lib/writeback/sessionattendancerecord.rb', line 60

def getDate()
    return self.date.to_s
end

#getSessionObject



64
65
66
# File 'lib/writeback/sessionattendancerecord.rb', line 64

def getSession()
    return self.session
end

#getStudentIdObject



51
52
53
# File 'lib/writeback/sessionattendancerecord.rb', line 51

def getStudentId()
    return self.student_id
end

#isValidObject



47
48
49
# File 'lib/writeback/sessionattendancerecord.rb', line 47

def isValid()
  return ! (self.getDate().empty? || self.getStudentId().empty? || self.getSession().empty? || self.getAttendanceCodeId().empty?)
end

#setAttendanceCodeId(attendanceCodeId) ⇒ Object



16
17
18
19
20
21
# File 'lib/writeback/sessionattendancerecord.rb', line 16

def setAttendanceCodeId(attendanceCodeId)
  if attendanceCodeId.empty? or attendanceCodeId.nil?
      throw InvalidAttendanceException, 'Attendance code id can not be set to null.'
  end
  @attendance_code_id = attendanceCodeId
end

#setComment(comment) ⇒ Object



85
86
87
# File 'lib/writeback/sessionattendancerecord.rb', line 85

def setComment(comment)
    self.comment = comment;
end

#setDate(date) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/writeback/sessionattendancerecord.rb', line 23

def setDate(date)
  if date.empty? or date.nil?
    throw InvalidAttendanceException, 'Date can not be set to null.'
  end
  begin
    mytime = Time.parse(date).to_i
  rescue
    throw InvalidAttendanceException, 'Date provided is invalid'
  end
  newdate = Time.at(mytime)
  self.date = newdate
end

#setSession(session) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/writeback/sessionattendancerecord.rb', line 37

def setSession(session)
    session = session.upcase

    if (session == 'AM' || session == 'PM')
        self.session = session
    else
        throw InvalidSessionException, 'The session is invalid'
    end
end

#setStudentId(studentId) ⇒ Object

most of these methods are here to be compatible 1:1 with the php module, standard ruby getters and setters should still work too



8
9
10
11
12
13
# File 'lib/writeback/sessionattendancerecord.rb', line 8

def setStudentId(studentId)
    if studentId.empty? or studentId.nil?
        throw InvalidAttendanceException, 'Student id can not be set to null.'
    end
    @student_id = studentId
end

#toArrayObject



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/writeback/sessionattendancerecord.rb', line 68

def toArray()
    required = {
      'date':               self.getDate(),
      'session':            self.getSession(),
      'student_id':         self.getStudentId(),
      'attendance_code_id': self.getAttendanceCodeId()
    }
    unless self.getComment.nil? or self.getComment.empty?
      required['comment'] = self.getComment()
    end
    return required
end