Class: UqamGradeNotification::Client
- Inherits:
-
Object
- Object
- UqamGradeNotification::Client
- Defined in:
- lib/uqam_grade_notification/client.rb
Instance Attribute Summary collapse
-
#notifier ⇒ Object
readonly
Returns the value of attribute notifier.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
-
#student ⇒ Object
readonly
Returns the value of attribute student.
Instance Method Summary collapse
- #grades_have_changed? ⇒ Boolean
-
#initialize(student, notifier, storage) ⇒ Client
constructor
A new instance of Client.
- #notify_of_changes ⇒ Object
- #save_student_grades ⇒ Object
- #student_last_grades ⇒ Object
Constructor Details
#initialize(student, notifier, storage) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 |
# File 'lib/uqam_grade_notification/client.rb', line 5 def initialize(student, notifier, storage) @student = student @notifier = notifier @storage = storage end |
Instance Attribute Details
#notifier ⇒ Object (readonly)
Returns the value of attribute notifier.
3 4 5 |
# File 'lib/uqam_grade_notification/client.rb', line 3 def notifier @notifier end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
3 4 5 |
# File 'lib/uqam_grade_notification/client.rb', line 3 def storage @storage end |
#student ⇒ Object (readonly)
Returns the value of attribute student.
3 4 5 |
# File 'lib/uqam_grade_notification/client.rb', line 3 def student @student end |
Instance Method Details
#grades_have_changed? ⇒ Boolean
22 23 24 25 |
# File 'lib/uqam_grade_notification/client.rb', line 22 def grades_have_changed? md5 = Digest::MD5.new md5.hexdigest(student.grades.to_json) == md5.hexdigest(student_last_grades.to_json) end |
#notify_of_changes ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/uqam_grade_notification/client.rb', line 11 def notify_of_changes if grades_have_changed? p "Grades have not changed since last checked." else = "Your grades have been updated!" p save_student_grades notifier.sms() end end |
#save_student_grades ⇒ Object
31 32 33 |
# File 'lib/uqam_grade_notification/client.rb', line 31 def save_student_grades storage.save_grades(student) end |
#student_last_grades ⇒ Object
27 28 29 |
# File 'lib/uqam_grade_notification/client.rb', line 27 def student_last_grades @last_grades ||= storage.last_grades(student) end |