Class: Meibo::Classroom

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

Direct Known Subclasses

JapanProfile::Classroom

Constant Summary collapse

TYPES =
{
  homeroom: "homeroom",
  scheduled: "scheduled"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(sourced_id:, title:, course_sourced_id:, class_type:, school_sourced_id:, term_sourced_ids:, status: nil, date_last_modified: nil, grades: [], class_code: nil, location: nil, subjects: [], subject_codes: [], periods: [], **extension_fields) ⇒ Classroom

Returns a new instance of Classroom.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/meibo/classroom.rb', line 45

def initialize(sourced_id:, title:, course_sourced_id:, class_type:, school_sourced_id:, term_sourced_ids:, status: nil, date_last_modified: nil, grades: [],
               class_code: nil, location: nil, subjects: [], subject_codes: [], periods: [], **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
  @title = title
  @grades = grades
  @course_sourced_id = course_sourced_id
  @class_code = class_code
  @class_type = class_type
  @location = location
  @school_sourced_id = school_sourced_id
  @term_sourced_ids = term_sourced_ids
  @subjects = subjects
  @subject_codes = subject_codes
  @periods = periods
  @extension_fields = extension_fields
end

Instance Method Details

#collectionObject



66
67
68
# File 'lib/meibo/classroom.rb', line 66

def collection
  Meibo.current_roster.classes
end

#courseObject



78
79
80
# File 'lib/meibo/classroom.rb', line 78

def course
  Meibo.current_roster.courses.find(course_sourced_id)
end

#enrollmentsObject



90
91
92
# File 'lib/meibo/classroom.rb', line 90

def enrollments
  Meibo.current_roster.enrollments.where(class_sourced_id: sourced_id)
end

#homeroom?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/meibo/classroom.rb', line 70

def homeroom?
  class_type == TYPES[:homeroom]
end

#scheduled?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/meibo/classroom.rb', line 74

def scheduled?
  class_type == TYPES[:scheduled]
end

#schoolObject



82
83
84
# File 'lib/meibo/classroom.rb', line 82

def school
  Meibo.current_roster.organizations.find(school_sourced_id)
end

#termsObject



86
87
88
# File 'lib/meibo/classroom.rb', line 86

def terms
  term_sourced_ids.map { |term_sourced_id| Meibo.current_roster.academic_sessions.find(term_sourced_id) }
end