Class: Meibo::Course

Inherits:
Object
  • Object
show all
Defined in:
lib/meibo/course.rb

Direct Known Subclasses

JapanProfile::Course

Instance Method Summary collapse

Constructor Details

#initialize(sourced_id:, title:, org_sourced_id:, status: nil, date_last_modified: nil, school_year_sourced_id: nil, course_code: nil, grades: [], subjects: [], subject_codes: [], **extension_fields) ⇒ Course

Returns a new instance of Course.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/meibo/course.rb', line 27

def initialize(sourced_id:, title:, org_sourced_id:, status: nil, date_last_modified: nil, school_year_sourced_id: nil,
               course_code: nil, grades: [], subjects: [], subject_codes: [], **extension_fields)
  raise InvalidDataTypeError unless subjects.is_a?(Array) && subject_codes.is_a?(Array) && subjects.size == subject_codes.size

  @sourced_id = sourced_id
  @status = status
  @date_last_modified = date_last_modified
  @school_year_sourced_id = school_year_sourced_id
  @title = title
  @course_code = course_code
  @grades = grades
  @org_sourced_id = org_sourced_id
  @subjects = subjects
  @subject_codes = subject_codes
  @extension_fields = extension_fields
end

Instance Method Details

#classesObject



56
57
58
# File 'lib/meibo/course.rb', line 56

def classes
  Meibo.current_roster.classes.where(course_sourced_id: sourced_id)
end

#collectionObject



44
45
46
# File 'lib/meibo/course.rb', line 44

def collection
  Meibo.current_roster.courses
end

#organizationObject



48
49
50
# File 'lib/meibo/course.rb', line 48

def organization
  Meibo.current_roster.organizations.find(org_sourced_id)
end

#school_yearObject



52
53
54
# File 'lib/meibo/course.rb', line 52

def school_year
  Meibo.current_roster.academic_sessions.find(school_year_sourced_id) if school_year_sourced_id
end