class UqamGradeNotification::Storage::LocalStorage

Attributes

base_path[R]

Public Class Methods

new(base_path=UqamGradeNotification::APP_DIR) click to toggle source
# File lib/uqam_grade_notification/storage.rb, line 12
def initialize(base_path=UqamGradeNotification::APP_DIR)
  @base_path = base_path
end

Public Instance Methods

last_grades(student) click to toggle source
# File lib/uqam_grade_notification/storage.rb, line 16
def last_grades(student)
  if File.exist?(grade_file(student))
    JSON.parse File.open(grade_file(student), "rb").read
  else
    ""
  end
end
save_grades(student) click to toggle source
# File lib/uqam_grade_notification/storage.rb, line 24
def save_grades(student)
  File.write(grade_file(student), student.grades.to_json)
end

Private Instance Methods

grade_file(student) click to toggle source
# File lib/uqam_grade_notification/storage.rb, line 30
def grade_file(student)
  "#{base_path}/#{student.code}_grades.json"
end