Class: Manabu::ClassGroup
- Defined in:
- lib/manabu/class_group.rb
Defined Under Namespace
Classes: Enrollment
Instance Attribute Summary collapse
-
#enrollments_count ⇒ Object
readonly
Returns the value of attribute enrollments_count.
-
#facility_id ⇒ Object
readonly
Returns the value of attribute facility_id.
-
#grade ⇒ Object
readonly
Returns the value of attribute grade.
-
#homeroom ⇒ Object
readonly
Returns the value of attribute homeroom.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#notes_count ⇒ Object
readonly
Returns the value of attribute notes_count.
Instance Method Summary collapse
- #add_student(student, args = {}) ⇒ Object
- #enrollments ⇒ Object
- #fill(**info) ⇒ Object
-
#initialize(client, **info) ⇒ ClassGroup
constructor
A new instance of ClassGroup.
- #students ⇒ Object
Methods inherited from Resource
Constructor Details
#initialize(client, **info) ⇒ ClassGroup
Returns a new instance of ClassGroup.
33 34 35 36 37 |
# File 'lib/manabu/class_group.rb', line 33 def initialize(client, **info) super @students = [] @enrollments = [] end |
Instance Attribute Details
#enrollments_count ⇒ Object (readonly)
Returns the value of attribute enrollments_count.
30 31 32 |
# File 'lib/manabu/class_group.rb', line 30 def enrollments_count @enrollments_count end |
#facility_id ⇒ Object (readonly)
Returns the value of attribute facility_id.
30 31 32 |
# File 'lib/manabu/class_group.rb', line 30 def facility_id @facility_id end |
#grade ⇒ Object (readonly)
Returns the value of attribute grade.
30 31 32 |
# File 'lib/manabu/class_group.rb', line 30 def grade @grade end |
#homeroom ⇒ Object (readonly)
Returns the value of attribute homeroom.
30 31 32 |
# File 'lib/manabu/class_group.rb', line 30 def homeroom @homeroom end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
30 31 32 |
# File 'lib/manabu/class_group.rb', line 30 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
30 31 32 |
# File 'lib/manabu/class_group.rb', line 30 def name @name end |
#notes_count ⇒ Object (readonly)
Returns the value of attribute notes_count.
30 31 32 |
# File 'lib/manabu/class_group.rb', line 30 def notes_count @notes_count end |
Instance Method Details
#add_student(student, args = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/manabu/class_group.rb', line 66 def add_student(student, args = {}) response = @client.post("class_groups/#{id}/enrollments", student_id: student.id ) Enrollment.new(@client, response).tap do |enrollment| @enrollments << enrollment end end |
#enrollments ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/manabu/class_group.rb', line 58 def enrollments if @enrollments.any? @enrollments else @enrollments = _fetch_enrollments end end |
#fill(**info) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/manabu/class_group.rb', line 39 def fill(**info) @id = info.fetch(:id, @id) @name = info.fetch(:name, @name) @grade = info.fetch(:grade, @grade) @homeroom = info.fetch(:homeroom, @homeroom) @notes_count = info.fetch(:notes_count, @notes_count) @enrollments_count = info.fetch(:enrollments_count, @enrollments_count) @facility_id = info.fetch(:facility_id, @facility_id) self end |
#students ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/manabu/class_group.rb', line 50 def students if @students.any? @students else @students = _fetch_students end end |